Why do I get the error message: BGI Error: graphics not initialized (use 'initgraph') when I use a graphics function? My program has already called initgraph().

For some reason initgraph() failed. To find out why, check
    the return value of graphresult(). For example:

      #include <graphics.h>
      main()
      {
        int gerr;   /* graphics error */
        int gdriver = DETECT, gmode;

        /* Initialize graphics using auto-detection and look
           for the .BGI and .CHR files in the C:\TURBOC directory.
        */
        initgraph(&gdriver, &gmode, "C:\\TURBOC");

        if ((gerr = graphresult()) != grOk)
        {
            printf("Error : %s\n", grapherrormsg(gerr));
            exit(1);
        }

               :
      }



Learn More :