#include <iostream.h>
#include<stdlib.h>
char ch;
int repeat;
int main()
{
repeat=1;
while(repeat==1){
printf("To continue enter 1. To quit enter 0. ");
ch = getchar();
if (ch=='1')
repeat=1;
else
repeat=0;
}
return 0;
}
The code compiles fine. However when I run it, the program accepts the char the first time, but when it repeats the while loop it won't accept a char in command prompt and exits the while loop and program. The code looks legit, but I'm not sure because I've only been using C for about 5 weeks now.
Any help is greatly appreciated.
Thank you!
Matrixaffiliate

New Topic/Question
Reply




MultiQuote





|