You are here

Getarcoords function in c

Declaration :- void getarccoords(struct arccoordstype *var);

getarccoords function is used to get coordinates of arc which is drawn most recently. arccoordstype is a predefined structure which is defined as follows:

struct arccoordstype
{
   int x, y;                /*   center point of arc    */
   int xstart, ystart;      /*   start position         */
   int xend, yend;          /*   end position           */
};

address of a structure variable of type arccoordstype is passed to function getarccoords.

C program of getarccoords

#include<graphics.h>
#include<conio.h>
#include<stdio.h>
 
main()
{
   int gd = DETECT, gm;
   struct arccoordstype a;
   char arr[100];
 
   initgraph(&gd, &gm,"C:\\TC\\BGI");
 
   arc(250,200,0,90,100);
   getarccoords(&a);
 
   sprintf(arr,"(%d, %d)",a.xstart,a.ystart);
   outtextxy(360,195,arr);
 
   sprintf(arr,"(%d, %d)",a.xend,a.yend);
   outtextxy(245,85,arr);
 
   getch();
   closegraph();
   return 0;
}

In the above program we have drawn an arc and then we get the coordinates of end points of arc using getarccoords.Coordinates so obtained are displayed using outtextxy.