View Single Post
  #3 (permalink)  
Old June 23rd, 2003, 07:21 AM
WilliansSantos WilliansSantos is offline
Registered User
 
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's very simple to build a function like gotoxy() using a software interruption. The following code do this and it works fine in any compile running on DOS (like Turbo C and Visual C)

#include <stdio.h>
#include <conio.h>
#include <dos.h>

void gotoxy (int x, int y)
{ union REGS regs;
  regs.h.ah = 2; /* cursor position */
  regs.h.dh = y;
  regs.h.dl = x;
  regs.h.bh = 0; /* vídeo page #0 */
  int86(0x10, &regs, &regs);
}

int main (void)
{ clrscr();
   movetoxy(35,10);
   printf("Hello\n");
   return 0;
}



Willians Santos
Software Engineer
Brazil
Reply With Quote