So, I was testing my understanding of the syntax for do-while loops and the toupper() function and ran into an odd error.
What is happening is, after the initial run it is printing "Type something in please:" and the newline in the printf that displays the result is printing twice. I suspect this has something to do with the keyboard buffer (still working on learning about that, so explain it in basic terms please )
Can anyone help me with a workaround/fix for this?
Code:
#include <stdio.h>
int main () {
char p;
int i=0;
do {
printf ("Type something in please: ");
scanf ("%c", &p);
p=toupper(p);
printf ("%c\n", p);
i+=1;
} while (i<10);
return 0;
}
Can anyone help me with a workaround/fix for this?