Posted by: KaLaNkIsThAn October 27, 2004
C Program help
Login in to Rate this Post:     0       ?        
and also your scanf("%c", &y); will run into problem coz it's in the while loop.... Works fine for the first loop, after that I am sure it will give you a problem. Think about this, you asked a user to enter a character... user enters a character... and hits the enterkey... so there is a newline also, which is \n, ie one character... so when the loop runs second time, it will read \n, and won't let a user to enter another character. There are bunch of ways to avoid this... one is use fflush(stdio); right after scanf. I think the other way is scanf(" %c", &something); NOTICE the space after " and %.
Read Full Discussion Thread for this article