English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How do you have a program ask if the user wants to continue with the current program that is running?

like:

char a;
char Y;
char N;

cout<<"Do you want to enter another value of Y? (Y/N)\n";
cin>>a;

if (a=Y)
{
//code
}

else if (a=N)
{
//code
}

return 0;
}

I can't get that to work, but thats the idea behind it I think, anyone want to help the newbie out : )!

2007-02-11 14:41:46 · 3 answers · asked by ? 2 in Computers & Internet Programming & Design

3 answers

check out http://www.pscode.com for great sample codes

2007-02-12 06:14:55 · answer #1 · answered by Richard H 7 · 0 1

you had it right in the first place, what was the problem you were having?

The second person that answered is correct, the comparasion operator is ==, I did not notice before.

2007-02-12 00:28:51 · answer #2 · answered by D 4 · 1 0

The comparison operator is == ie.

if (a==y)

and you need to initialiase the y="Y" etc.

2007-02-12 00:40:26 · answer #3 · answered by KtheK 1 · 1 0

fedest.com, questions and answers