This blog is under construction

Wednesday, 11 September 2013

getdrivername example in c

Header file:
    graphics.h

Synopsis:
      char *getdrivername (void);
     
Description:
     getdrivername() returns name of the currently loaded graphic driver.



getdrivername function in c graphics



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

  int main(void) {
        /* request auto detection */
        int graphicDriver = DETECT;
        int graphicMode, err;

        /* stores the device driver name */
        char *driver, buf[256];

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

        setcolor(getmaxcolor() / 2);

        /* get name of the device driver in use */
        driver = getdrivername();

        sprintf(buf, "Device Driver => %s", driver);

        /* output the name of the driver */
        outtextxy(50, 50, buf);

        getch();

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





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


No comments:

Post a Comment