Complicated response- just please look at it, too long to fit in title

Hey,
So I'm writing this fairly low-end program (just if's else, cout, cin) trying to emulate a (pretty bad) simulator. Here's my code:


// SimTalk.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

void main()
{
char resp[20] ;
char resp2 [20];
char ext;





cout<<"Hey, how are you? \n\n";
cin>>resp;

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?

Thanks!
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.
thanks (both of you)
Topic archived. No new replies allowed.