Hi all, this is my first post on the forum and I hope I can get some help with my problem.
I need to make a program to extract the last word from a sentence. I managed to extract the last character, but I have no idea how to get a word.
Any help is appreciated!Code:#include <iostream> #include <string> using namespace std; int main() { string strSentence = "Today will rain"; int intLength; intLength = strSentence.length(); cout << "\nThe last character of " << strSentence << " is a " << "'" << strSentence.substr(intLength - 1,1) << "'" ; cout << endl; system("PAUSE"); return 0; }//end main



LinkBack URL
About LinkBacks



