I have included graphics.h in Codeblock and used initgraph() to rezise my console window. It can compile but it only outputs a default black window which return "Process returned -1073741819 (0xC0000005) execution time : 2.970 s Press any key to continue.."
#include <iostream>
#include <graphics.h>
using namespace std;
int main(){
initgraph(1000,800);
getch();
closegraph();
}
Abandon graphics.h and use a modern graphics library. graphics.h is the header for the Borland Graphics Interface (BGI), a library shipped with the Borland development tools of the 1980s and early 1990s and intended for use with the DOS operating systems. It is old. Use of it professionally is exceptionally rare, so there is minimal value in learning it when you could be learning a graphics library that is used professionally and supported by modern development environments and hardware. For example, the graphics tools built into SFML and SDL.
If this is for school and you must use an implementation of graphics.h to satisfy the marking criteria, either
As I recall the implementation of graphics.h most commonly suggested online required GCC3.4, and the odds of you getting Code::Blocks with GCC less than 4.8 these days is astonishingly small. And even version 4.8 is horribly out of date. Mainstream GCC is on 10.2.
To add to the fun, the library will have been written to run on the then-flagship Windows XP operating system and the graphics cards available at the time. Both have changed dramatically since then. So even if you track down GCC 3.4, successfully install it, and configure Code::Blocks to use it, you may find yourself needing Windows XP and a vintage 2005 graphics card because there's no way Windows XP will have a driver for whatever graphics card you are using.
This means your code can be 100% correct but the library you are using simply does not run as expected with the tools you're using. Your only option is to use other tools or use a different graphics library.
User contributions licensed under CC BY-SA 3.0