c++ - scanf causes loop to terminate early -


c='q'; while(c=='q')  {    printf("hello");    scanf("%c",&c);  } 

why loop exit without reason on taking input?

i'm going assume want user input of 'q' mean quit, , want loop exit when c == 'q'.

try:

c='\0'; while(c !='q')  {    printf("hello");    scanf("%c",&c);  } 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -