From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Help Date: Thu, 19 Feb 1998 18:49:52 -0500 Organization: Two pounds of chaos and a pinch of salt. Lines: 46 Message-ID: <34ECC520.3F01@cs.com> References: <34ec84f8 DOT 2393449 AT news DOT dial DOT pipex DOT com> NNTP-Posting-Host: ppp204.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Richard Ward wrote: > > The key presses and exit routines wouk ok, (i have removed the some of > the cases to make the below smaller), but the display routines do not > work. I have tested the print_at routine on its own and it works > fine. > > At this rate I think I will not continue programming as if this fools > me god help me in the future. All I can think of is that its > something to do with the compiler not compiling the instructions in > the right order, something with I have problems with Xenix 1987 > version. > print_at(20,1,"Enter Option : "); > result=getch(); It's as simple as this: conio and stdio functions are not compatible. Specifically, stdout is line-buffered by default in DJGPP v2.01, which means that the string, "Enter Option : " is not displayed on the screen until one of the following occurs: - You print a newline. - You call fflush(stdout). - The internal stdout buffer overflows. - You call a stdio input function. Note that getch() is a conio input function, and does not invoke the fourth rule. Similarly, gotoxy() is a conio positioning function, and has no effect on the stdout buffer. I recommend manually flushing stdout inside your print_at() function; this should solve the problem completely, if inelegantly. For an even less elegant solution, you could remove buffering from stdout. A third solution would be to rewrite print_at() to use conio output, especially since it calls gotoxy(). A fourth solution will arrive when DJGPP v2.02 comes out; the line buffering problem will be worked around. It's generally a bad idea to mix stdio and conio functions no matter what compiler you use. -- --------------------------------------------------------------------- | John M. Aldrich, aka Fighteer I | mailto:fighteer AT cs DOT com | | "Starting flamewars since 1993" | http://www.cs.com/fighteer/ | | *** NOTICE *** This .signature | ICQ UIN#: 7406319 | | is generated randomly. If you don't like it, sue my computer. | ---------------------------------------------------------------------