www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/10/22:29:11

From: j DOT aldrich6 AT genie DOT com
Message-Id: <199607110221.AA137891700@relay1.geis.com>
Date: Thu, 11 Jul 96 02:01:00 UTC 0000
To: merser AT image DOT dk
Cc: djgpp AT delorie DOT com
Mime-Version: 1.0
Subject: Re: gotoxy

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019