This blog is under construction

Thursday, 12 September 2013

getmodename example in c

Header file:
    graphics.h

Synopsis:
      char *getmodename (void);
     
Description:
     getmodename() gets the name of the current graphic mode.


getmodename function in c graphics



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

  int main(void) {
        /* request autodetection */
        int graphicDriver = DETECT, graphicMode;
        int err, mode;
        char gmode[256];

        /* 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));
                return 0;
        }

        /* get mode number and name strings */
        mode = getgraphmode();

        sprintf(gmode, "mode number is %d and "
                "graphics mode is %s.", mode, getmodename(mode));

        /* display the information */
        outtextxy((getmaxx() / 2) - 200, getmaxy() / 2, gmode);

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





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


No comments:

Post a Comment