You are here

getx and gety gunction in c

Declarations :-
int getx();
int gety();

getx function returns the X coordinate of current position.
gety function returns the Y coordinate of current position.

Example Program of getx and gety functions :

#include<graphics.h>
#include<conio.h>
#include<stdlib.h>

int main()
{
	int gd = DETECT, gm;
	int x, y;
	char a[100];

	initgraph(&gd,&gm,"C:\\TC\\BGI");

	moveto(200 + random(100),100 + random(100));

	circle(getx(), gety(), 50);

	getch();
	closegraph();
	return 0;
}

Note: Current Position is sometimes written as CP in short.