getx() function in C
Last Updated :
25 Jan, 2018
The header file graphics.h contains getx() function which returns the X coordinate of the current position.
Syntax :
int getx();
Example :
Explanation : Initially, the X coordinate of the current position is 0. On moving the coordinates using moveto() function, the X coordinate changes to 80.
Below is the implementation of getx() function:
#include <graphics.h>
#include <stdio.h>
int main()
{
int gd = DETECT, gm;
char arr[100];
initgraph(&gd, &gm, "" );
sprintf (arr, "Current position of x = %d" ,
getx());
outtext(arr);
moveto(80, 50);
sprintf (arr, "Current position of x = %d" ,
getx());
outtext(arr);
getch();
closegraph();
return 0;
}
|
Output :
Share your thoughts in the comments
Please Login to comment...