Tuesday, February 23, 2010

  • The gotoxy() funtion is used to simply move the cursor on your monitor screen wherever desired.
  • It is declared in the "conio.h" header file.
  • It takes 2 parameters, gotoxy(int x, int y). The 1st parameter specifies the x-co-ordinate on the screen, i.e., horizontal position(from left to right) on the screen. The 2nd parameter specifies the y-co-ordinate on the screen, i.e., Vertical position(from top to bottom) on the screen. Thus, gotoxy(1,1) tells the compiler to move the cursor to the left-top-most corner of the screen.
  • The use is demonstrated in the following example:
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("This is the normal cursor position.");
gotoxy(36,25);
printf("This is the changed cursor position.");
getch();
}