Simple input/output issue.

May 26, 2012 at 3:49pm
Hi guys,
I am trying to write simple question and get answer on it , but how i will identify answers if the answer contain one word which help me to write my second answer for example

cout <<"ARE YOU ACTOR, EDITOR OR CAMMERAMAN?! " << endl;

How i can identify the answer if the user used below answers.

I am Actor.
or
Actor.

so i can go for the next question based on the answer.

Thanks in advance.
May 26, 2012 at 4:12pm
closed account (o3hC5Di1)
You could use numbers that represent the options and validate those, like:

1
2
3
4
cout <<"Are you 1) an actor, 2) an editor, 3) a cameraman ? " << endl;
getline(cin, input);
stringstream(input) >> number;
if (isdigit(number)) ...


Hope that helps.

Al the best,
NwN
Last edited on May 26, 2012 at 4:17pm
May 26, 2012 at 4:16pm
I'd have to agree with NwN's idea. The easiest way to do this would be to associate each possible choice with an integer or a char value, prompt for the input, then use the int (or char) value to determine the next step in the program.
Topic archived. No new replies allowed.