From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: (possible) printf bug Date: Sun, 08 Dec 1996 22:07:35 -0800 Organization: Three pounds of chaos and a pinch of salt Lines: 34 Message-ID: <32ABACA7.2C70@cs.com> References: <01bbe56f$dd5b4f60$666fd9ce AT scully> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp108.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: Cephaler DJ-Gateway: from newsgroup comp.os.msdos.djgpp Cephaler wrote: > > printf("Loading prefs..."); > .... > window(1,1,80,4); > cprintf("Choose an option:\n\r1) start\n\r2) load\n\r3) quit\n\r? "); > fscanf(" %d", &choice); Under DJGPP, stdout is line buffered, so anything you write with printf(), puts(), putchar(), etc, will not show up until one of the following occurs: - You print a newline to stdout. - You flush stdout. - You invoke an input function which reads from stdin. - You overflow the internal stdout buffer. - You issue a sync() or other command which affects all open files. - Your program exits. In your program, you are mixing functions with functions, which always leads to trouble. For example, if somebody were to redirect the stdout of your program with "prog >prog.out", "Loading prefs..." would be written to prog.out, and the rest of the text would show up on the screen. Very bad behavior. In short, if you're going to use in a program, all its input and output should be done using functions. -- --------------------------------------------------------------------- | John M. Aldrich, aka Fighteer I | fighteer AT cs DOT com | | Plan: To find ANYONE willing to | http://www.cs.com/fighteer | | play Descent 2 on DWANGO! | Tagline: | ---------------------------------------------------------------------