This blog is under construction

Thursday, 12 September 2013

graphresult example in c

Header file:
    graphics.h

Synopsis:
      int graphresult();
     
Description:
     graphresult() returns error code for failed graphics operation or returns grOk for successful graphics operation.


graphresult function in c graphics



  #include <stdio.h>
  #include <conio.h>
  #include <graphics.h>
  #include <dos.h>

  int main() {
        /* request auto detection */
        int graphicDriver = DETECT, graphicMode;
        int err, midx, midy;
        int circleRadius = 150;

        /* initialize graphics system */
        initgraph(&graphicDriver, &graphicMode,
                                        "C:/TURBOC3/BGI");
        err = graphresult();

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

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

        /* draws a line from (0, 0) to (midx, midy) */
        line(0, 0, midx, midy);

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





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


No comments:

Post a Comment