Simple C program exits prematurely -


I'm trying to create a program (my first) which asks users for four inputs, and long It's been running from time to time that the four ASCII values ​​are not 0. However, my code never reaches the loop part and always exits after the initial printf statement. I'm sure there was no problem in the loop by adding a printf statement before the loop and it still did not execute.

  #include & lt; Stdio.h & gt; Int main (zero) {four c; Printf ("Welcome to ASCII Land:"); Scanf ("% c", & amp; c); While ((int) 'c'! = 0) {printf ("type in other type"); Scanf ("% c", & amp; c); } Printf ("You've done"); Return 0; }  

while ((int) 'c'! = 0) { should be while (c! = '0') {

By default it converts 'C' to a number and compares to 0. C 'is actually 99, so you're saying while (99! = 0) . Just by removing quotation marks from 'c', how do you "enter? ASCII 0 (NUL)"?


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -