C++ Question....thanks for any help you can give

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
J

C++ Question....thanks for any help you can give

Post by J »

I only took 1 C++ class and am trying to remember how to write code to reloop my code. I wrote a program that asks the user to answer 5 questions, and it tells them which weather model to use based on the answers they submit. But I don't remember how to make code so that I can ask at the end if they want to test another time. Basically I have an output statement asking "Would you like to test another model (Y=Yes, N=No)" but I don't know the code to actually go through the code again. Thanks for the help
Khumba

RE:C++ Question....thanks for any help you can give

Post by Khumba »

char c;
do {
   ... code ...
   printf("Again (Y/N)? ");
   scanf("%c", c);
} while (c != 'y' && c != 'Y');
Anton

RE:C++ Question....thanks for any help you can give

Post by Anton »

You probably ment:

char c;
do {
   ... code ...
   printf("Again (Y/N)? ");
   scanf("%c", &c);//!!!!!!! &c not c
} while (c != 'y' && c != 'Y');

Anton.
Post Reply