Hi all
I found this weird problem which I hadn't seen before. I was working on Cygwin (the problem later replicated on a real linux box as well). I was writing a program where I needed to do something like:
Code:
while(ch == 'y')
{
x = myfunc();
//do something ...
printf("\n Enter y to insert again:");
scanf("%c",&ch); // I tried using getchar() and getch() also.
}
Now my problem is that this loops only once whatever input I give. The first time it loops correctly, the 2nd time it gets into the lopp and exits after the printf. I tried using fflush() but that didn't help either. Am I doing something really stupid?
Thanks