This blog is under construction

Thursday, 12 September 2013

gety example in c

Header file:
    graphics.h

Synopsis:
      int gety (void);
     
Description:
     gety() returns y-coordinate of current graphics position.


gety function in c graphics



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

  int main(void) {
        /* request auto detection */
        int graphicDriver = DETECT, graphicMode;
        int err, midx, midy;
        char str[80];

        /* initialize graphics and local variables */
        initgraph(&graphicDriver, &graphicMode, "C:/TURBOC3/BGI");

        /* read result of initialization */
        err = graphresult();

        if (err != grOk) {
                /* an error occurred */
                printf("Graphic Error: %s\n",
                                grapherrormsg(err));
                getch();
                return 0;
        }

        /* mid position in x and y-axis */
        midx = getmaxx() / 2;
        midy = getmaxy() / 2;

        /* move to the screen center point */
        moveto(midx, midy);

        /* create a message string */
        sprintf(str, "current position of "
                "y coordinate is %d", gety());

        /* setting the current drawing color */
        setcolor(WHITE);

        /* sets the current text style */
        settextstyle(TRIPLEX_FONT, HORIZ_DIR, 3);

        /* sets text justification */
        settextjustify(CENTER_TEXT, CENTER_TEXT);

        /* prints the given string */
        outtext(str);

        /* clean up */
        getch();
        closegraph();
        return 0;
  }





Output: (gety built-in function in c graphics.h)


No comments:

Post a Comment