Mail Archives: djgpp/1997/06/30/05:12:44
---Justin Talbot <stevetalbot AT sandiegoca DOT ncr DOT com> wrote:
>
> Two problems:
>
> First if I compile and run a simple program:
> void main(void)
> {
> printf("Hello world");
> getch();
> }
> The computer waits for me to press a key, then prints "Hello world",
> then ends. The compiler esentially switches the two function calls.
> This also happens if I place two getch()s after the printf()
statement,
> except it waits for two key presses before printing "Hello world."
>
> Am I doing something very wrong? Is this a known problem with the
> compiler? Or is this something wrong with my copy?
>
You could always use setvbuf to flush out the stdout.
eg....
void main(void)
{
setvbuf(stdout, NULL, _IONBF, 0);
printf("Hello world");
getch();
}
instead of ...
void main(void)
{
printf("Hello world");
flush();
getch();
}
where you have to flush each time you use the printf function. (kinda
silly)
_____________________________________________________________________
Sent by RocketMail. Get your free e-mail at http://www.rocketmail.com
- Raw text -