This blog is under construction

Wednesday 11 September 2013

getgraphmode example in c

Header file:
    graphics.h

Synopsis:
      int getgraphmode (void);
     
Description:
     getgraphmode() returns the current graphics mode.



getgraphmode example in c



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

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

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

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

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

        /* get mode number and name strings */
        sprintf(modenum, "Graphic mode number: %d",
                                        getgraphmode());
        sprintf(modename, "Graphics mode: %s",
                                getmodename(getgraphmode()));

        /* display the information */
        outtextxy(100, 100, modenum);
        outtextxy(100, 130, modename);

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





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


No comments:

Post a Comment