Mail Archives: djgpp/1998/02/19/21:11:56
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. |
---------------------------------------------------------------------
- Raw text -