You need to fflush(stdout) after your call to printf(). printf() only flushes its buffers when it prints a newline ("\n").
Also, because of https://bugs.eclipse.org/bugs/show_bug.cgi?id=27663 doing printf() to the Eclipse console doesn't flush until printf()'s buffer becomes full. CC yourself or vote for it if you're interested.
Cheers //Johan
================================================================
Keith059 wrote / skrev:
Eclipse Platform v3.0.1 and CDT v2.0.2 Compiler cygwin
AMD Athlon 1600 XP Windows XP
Can anyone help? I am new to eclipse and have run into a problem with the console display when I use the C 'scanf' function as in the following demo:
/* scanf demo */
#include
int main()
{
char str[80]
printf("Enter your surname: ");
scanf("%s",str);
printf("Hello Mr. %s",str);
return(0);
}
When the program is Run the console does not display anything until I input a name. That is, the console does not display the "Enter your surname:" prompt until after I input a surname! The following is the consoles display when the program terminates:
Woodward
Woodward
Enter your surname: Hello Mr. Woodward
댓글 없음:
댓글 쓰기