heyy all ,, i'm trying to get the middle word of sentence contains 3 words using find and substr.. this is the code : #include <iostream> #include <string> using namespace std; void main() { string sentence; cout << "enter a three-words sentence :"; getline(cin, sentence); string middle = sentence.substr(sentence.find(" ") + 1, sentence.find(" ")); // find the middle word cout << middle << endl; //Print the middle word system("pause"); } so guys what is the solution!!please be helpful :) <3

Member Avatar
Member Avatar
+0 forum 7

xhi, my task is to make a script, which displays the string read from console input in the form of 1 letters / line only. my code looks like this so far read string hossz=`expr length "$string"` for i in `seq 1 $hossz` do echo `expr substr $string $i 1` done my problem is that if the string contains spaces, i only get a bunch of expr syntax errors, else its working correctly. i tried using the tr command to change the spaces into "\n" but i failed to do that too :(. also tried googleing but i couldnt find …

Member Avatar
Member Avatar
+0 forum 2

Hi Everyone, How can I add a + sign to the following string.... for some reason I just can not figure it out I have tried ".+ and ".+." and sign quotes - both options but it just doesnt seem to work for me.... $number = $Code."".substr( $mobnum, 0 ); So, number will be the international code of the country plus the sms text message for example 4401234567890 for UK numbers but for international numbers I am trying to add the + sign So it reads +11234567890 for the US... Hope someone can help & explain where I am going …

Member Avatar
Member Avatar
+0 forum 3

How function can I use for search substr in str?

Member Avatar
Member Avatar
+0 forum 2

I have a string, that contains multiple values, and has a prefix of ***. Here's an example: [code=php] $value = 'a.first_name, a.last_name, a.address, a.city, a.state, b.phone_num, bc.gender, vfr.rating'; // instead, I'd like for it to display like this $value = 'first_name, last_name, address, city, state, phone_num, gender, rating'; [/code] Basically, I'd like to remove the "." and everything that comes before it for each element. As you can see, the prefix may contain 1-n characters to remove. How might I accomplish this? Thanks in advance! -E

Member Avatar
Member Avatar
+0 forum 1

write a program that will identify the longest substring in two given strings that is common to both.

Member Avatar
Member Avatar
+0 forum 5

Hi, I am using substr to bring back only the first few lines of text from a database field - For example: $message_contents = substr($message_contents, 0, 43); How can I protect against the substr to deliver the next full word ? so, if my 44th,45th,46th charachters were (com) currently the substr will just deliver daniweb. ?? but I would like to display all of the last word any pointers as always will be very much appreciated -

Member Avatar
Member Avatar
+0 forum 1

The End.