gotoxy function >> conio.h header file >> Move Cursor to Specified Position
Basic You Should know ?
Header File : conio.h
Function : gotoxy
Return Type : Void
Purpose :
- Positions cursor in text window .
- Moves Cursor to Position Specified i.e at (x,y)
- If the coordinates are invalid, the call to gotoxy is simply ignored by Compiler
- The origin is located at (1,1) the upper-left corner of the window
- Maximum x Co-ordinate in Text Mode = 80.
- Maximum y Co-ordinate in Text Mode = 25.
Syntax :
void gotoxy(int x, int y);
- x represents “New X Co-ordinate”
- y represents “New Y Co-ordinate”
#include<stdio.h>
#include<conio.h>
int main(void)
{
clrscr();
gotoxy(50,15);
printf("Hello world");
getch();
return 0;
}
Care Should be Taken :
gotoxy(50,15);
printf("nHello world");
- In the Above Example You will unable to see expected Output instead Output will be printed at position (1,16) because of leading Newline Character (n) in printf
Example of invalid coordinates:
gotoxy(40,30) /* (35,25) = window's bottom right position */