From: G DOT DegliEsposti AT ads DOT it To: "Ian Perez" cc: djgpp AT delorie DOT com Message-ID: Date: Thu, 4 Jun 1998 09:38:53 +0200 Subject: Re: Re: Gotoxy() Malfunction Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii Precedence: bulk >>> -The cursor's position isn't as I wrote or >>> -The cursor's position is O.K. but the printf() function I wrote doesn't >>> appear. After quiting the program I press Alt+F5 and what a surprise that >>> all sentences wroten (write) appear at the bottom of the screen. >> >>You are using gotoxy together with printf. This is a bad idea, since >>direct console I/O and stdio functions don't mix well. Use cprintf >instead. The DJGPP FAQ list (available as v2/faq210b.zip from the same >place you get DJGPP) discusses this in more detail in section 9.4. > >I had that problem for the longest time, but I finally figured it out. When >you use printf() or gotoxy(), for some reason, it doesn't show up on the >screen until the program exits. But if you use fflush(stdout) after a >printf() or gotoxy(), it should clear up the problem. I hope it works out >:) Actually these are two distinct problems: printf is line buffered. This means it writes only when a whole line is output (ie when a \n is output) or when you force it to print using fflush(stdout). You see the output at program exit only because all files are flushed and closed at program exit, if you printf some \n within the program you will see the lines on the screen before the program exit. What Eli was talking about is another matter: printf and gotoxy belong to different parts of the clib: gotoxy belongs to the conio functions, which are console-specific functions. Printf is a stdio function, so it doesn't know anything about console specific issues, such as the cursor position and so on. This way each function goes on working according to its knowledge of the cursor position, giving unexpected results. The best solution is use only one set of functions and not mix them. ciao Giacomo ciao Giacomo