string characters problem

What i need is if someone types in some word, it is stored in a string and get last two character of the string, and create some functions basing on those last characters, Such of if last two characters are "is" , some function. SO like that, I cant figure out how to do this, Please tell me how to and give me the code,

Thanks
Please help, I desperately need this quick (real )
Enter a word goes like so:
1
2
std::string word;
std::cin >> word


Getting the last two characters like so:
1
2
3
std::string last_2 = word.substr(word.size() - 2);
if(last_2 == "is")
  DoSomething();


EDIT: Take care that the word has at least 2 characters
Last edited on
thanks alot, But can you give me the full code? with include and return if it doesnt have 2 character, Sorry im noob to c++ , I have experience in others. So please help

Thanks
can you give me the full code?

Aw... unfortunately that's one of the few things we'll refuse to do on this forum that's socially acceptable. We have a policy against giving out full solutions, which believe it or not is for the good of the people who need help. :/

-Albatross
Why is that so? But i
Ok i figured it out thanks for not helping me, I gained some experience. And how can i convert this code into GUI instead of dos, without Basic (I use visual c++ 2005) anyway i could do it?
If you want to have a GUI, you'll need to get familiar with a GUI framework such as wxWidgets, Qt or gtkmm.
If you have a masochistic streak, you can have a GUI using pure WinAPI too.
Topic archived. No new replies allowed.