Search code examples
c++ccodeblocksbgi

graphics.h not working in code blocks with MinGW in windows 7 64bit


I had setup the graphics file necessary for the execution of the graphics code in CodeBlocks from the following sites:-

http://www.codewithc.com/how-to-include-graphics-h-in-codeblocks

then I tried this sample code.

#include <graphics.h>
int main( )
{
     initwindow(400, 300, "First Sample");
     circle(100, 50, 40);
     while (!kbhit( ))
     {
         delay(200);
     }
     return 0;
}

but when I Run the code in code blocks I get this

draw.exe has stopped working...

output of the program

Can anyone resolve my problem?


Solution

  • This is because graphics.h is Borland's BGI graphics library from 1989, developed for 16 bit MS DOS computers. But you are using a 64 bit Windows computer.

    Solution: don't use 28 years old, non-standard libraries.