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
Post a Comment