Someone told me to use this to clear input buffer
...and now this is giving me a warning:Code:while((ch=getchar())!='\n' && ch!=EOF);
13:3: warning: no newline at end of fileCode:#include<stdio.h> int main() { char a,b,ch; printf("\nEnter a character:"); a=getchar(); while((ch=getchar())!='\n' && ch!=EOF); printf("\nEnter another one:"); b=getchar(); while((ch=getchar())!='\n' && ch!=EOF); printf("You entered %c and %c\n",a,b); return 0; }
The program works as expected, though.