Message-ID: <19970630091100.1690.rocketmail@send1.rocketmail.com> Date: Mon, 30 Jun 1997 02:11:00 -0700 (PDT) From: Jeffery Guan Subject: Re: printf() and shl Questions To: djgpp AT delorie DOT com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Precedence: bulk ---Justin Talbot 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