Community
Participate
Working Groups
I have the following C program in CDT on Windows, using MinGW (gcc 6.3.0, gdb 7.6.1) as the compiler: #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { int a = 0; int count = 0; //setbuf(stdout, NULL); //setvbuf(stdout, NULL, 0, _IONBF); char buf[50]; for (;;) { memset(buf, 0, sizeof(buf)); printf("%d Enter a word: ", ++count); fflush(stdout); scanf("%49s", buf); printf("%d word is \"%s\"\n", ++count, buf); fflush(stdout); if (strcmp(buf, "done") == 0) break; } printf("%d enter a number:", ++count); fflush(stdout); scanf("%d", &a); printf("%d The number is %d\n", ++count, a); fflush(stdout); while (1) {} return EXIT_SUCCESS; } When run, I get the following output (I enter "a", "b", "done", and "321" each on separate lines): 1 Enter a word: 2 word is "41-thread-select" 3 Enter a word: 4 word is "1" a 5 Enter a word: 6 word is "a" b 7 Enter a word: 8 word is "b" done 9 Enter a word: 10 word is "done" 321 11 enter a number:12 The number is 321 I see a few problems here. There is spurious input when the program starts: "41-thread-select" and "1", and fflush does not force the output buffer to appear. Neither the calls to setvbuf nor setbuf make any difference in the output. These problems do go away if the external console is used. This program can be used to test CDT and the internal console once conpty support is completed.