if ((strcmp ("bad", resp) == 0) || (strcmp("not", resp) == 0) || (strcmp("un", resp) == 0))
{
cout<<" Whoah! What happened?!";
cin>>resp2;
if ((strcmp ("don't",resp2) ==0) || (strcmp ("later",resp2)==0))
cout<<"Okay, I'll see you later then";
cin>>ext;
return;
} else{
cout<<"I am twelve years old";
cin>>ext;
return;
}
return ;
}
Here's what i want it to do, if I answer the question"How are you?" with a sentence (without any spaces of course) including either the word "bad", "not", or "un" [like "badly", or "nottoowell", or "unhappy"] i want it to ask "Whoa! what happened?" Then I input my answer, and if my answer includes "don't", or "later" ["Idon'twanttotalkaboutit, or "tellyoulater"], it'll close the program after saying "Okay, see you later, then". However, when when i build the program and run it, it only accepts the words "bad" "un" "not" etc, and not larger words with those one in them? How do i fix this so i can get my desired outcome as explained above?
If you use getline() and get the data into an std::string, you can use check the find() function to see if the string contains a sequence of characters.
Also, for future reference, I think a title for this might be something like "string parsing" or something to that effect.