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:

  1. struct arccoordstype
  2. {
  3.    int x, y;                /*   center point of arc    */
  4.    int xstart, ystart;      /*   start position         */
  5.    int xend, yend;          /*   end position           */
  6. };

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

C program of getarccoords

  1. #include<graphics.h>
  2. #include<conio.h>
  3. #include<stdio.h>
  4.  
  5. main()
  6. {
  7.    int gd = DETECT, gm;
  8.    struct arccoordstype a;
  9.    char arr[100];
  10.  
  11.    initgraph(&gd, &gm,"C:\\TC\\BGI");
  12.  
  13.    arc(250,200,0,90,100);
  14.    getarccoords(&a);
  15.  
  16.    sprintf(arr,"(%d, %d)",a.xstart,a.ystart);
  17.    outtextxy(360,195,arr);
  18.  
  19.    sprintf(arr,"(%d, %d)",a.xend,a.yend);
  20.    outtextxy(245,85,arr);
  21.  
  22.    getch();
  23.    closegraph();
  24.    return 0;
  25. }

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.