Issue
I tried to ran this code :
printf("Enter a character.");
printf("\n");
do {
ch = getch();
system("cls");
putchar(ch);
} while(ch != '.');
The above code works fine on Codeblocks but it is not working on Eclipse IDE. In fact the printf
statement before do while
loop is not working, but if I disable do while
statement the printf statement working fine on eclipse. Could you explain why is this happening ?
Solution
Maybe try this?
printf("Enter a character.\n");
fflush(stdout);
do {
ch = getch();
system("cls");
putchar(ch);
} while(ch != '.');
I think it's because your output buffer (printf) is not flushed.
Answered By - Ashhar Shah