C++ string imput

Hi-
I'm making a program which requires people to inmput a string and I wasn't sure if it was possible to make the program look for specific words like what, is, pi, ect...
If it is what kind of code would i use?
                              -thanks
                                Durion
DurionAsked:
Who is Participating?
 
tinchosConnect With a Mentor Commented:
if i were you, i would read all the words and then parse it

#include <string>

bool done = false;

while( !done )
{
  std::string input;

  input << std::cin;

  switch( input )
  {
     case "What" : doSomething(); break;
     case "pi" : doSomethingElse(); break;
     case "is" : doSomethingElse2(); break;
  }
  // set done = true when done parsing

}
0
 
DurionAuthor Commented:
thanks a lot!!!
0
 
tinchosCommented:
ok, glad it helped

accept the comment as an answer and we're done
:D

0
All Courses

From novice to tech pro — start learning today.