Mail Archives: djgpp/1996/07/15/13:31:19
Reply to message 1229026 from ET# on 07/08/96 3:24PM
>Do anyone know why 'gotoxy(int x, int y)' dosn't work.
>It just doesn't move the cursor correct? The coordinates is within
>screen limits.
>The program works just fine when compiled with Borland 5.0 (16-bit
>and Win32).
Are you using calls to printf() after you call gotoxy()? Under DJGPP,
stdout is line-buffered, so unless you use fflush() after every call to
printf() (or related functions like putchar(), puts(), etc.) you will see
skewed output.
For example, the following code fragment:
gotoxy(5,5);
printf("Hello "); <- goes into buffer, but isn't displayed
gotoxy(10,10);
printf("World\n"); <- \n flushes entire buffer at current cursor pos
will print "Hello World" at (10,10), instead of the desired results.
What you need to do is use the correct set of output functions. conio.h
comes with the functions cprintf(), cputchar(), cputs(), cscanf(), and more,
all of which are designed to interact directly with the screen in the same
way that gotoxy() works. These functions are NOT buffered, so whatever
they output goes immediately to the screen.
If the above doesn't solve your problem, then please post a DETAILED
description of the error(s) (possibly even including a screen capture of
the erroneous output), plus a sample program that demonstrates the
error, and we'll get back to you.
John
P.S.: Hundreds of programmers have been using gotoxy() since DJGPP
came out and they haven't reported any errors. If you have a problem,
chances are it's something you did, not an bug in DJGPP. A question
like "Why doesn't XXX work?" is completely meaningless without some
concrete description of the problem so we can figure out what went
wrong.
- Raw text -