newbie cin help
Ok im new at this and trying to learn but im having problems trying to write an or function for cin. Heres what im trying to do but the or function doesnt work. It will run but it always comes up false.
I Hope someone can help me out. if you have any ideas or think you can help let me know.
cin.getline ( resp1, 50 );
if ( strcmp ( resp1, "answer1 || answer2") == 0)
Let me guess: you want to check if resp1 is equal to "answer1" or "answer2". The solution is to write:
But really, you should be using std::string, in which case your entire snippet could be simplified to:
if (strcmp(resp1, "answer1") == 0 || strcmp(resp1, "answer2") == 0)
if (resp1 == "answer1" || resp1 == "answer2")
cout << "Outputted text\n";
cout << "outputted text\n";
Laserlight you are amazing. thanks for the fast help. Not only did you help me solve my issue but you also made it much more simplified.