You are here

getx and gety functions in C

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

Function getx returns the X coordinate of the current position.
Function gety returns the Y coordinate of the 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.