I am running Windows 10 on VirtualBox and after installing MinGW manually, I configured the Code::Blocks compiler to its directory.
I have also copied the graphics.h
library and header file in my MinGW directory and linked it in Code::Blocks by following steps in this link
My .cpp
file compiles properly but I get this runtime error everytime:
Process returned -1073741819 (0xC0000005) execution time : 2.885 s
Press any key to continue.
Here is my code:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request autodetection */
int gdriver = DETECT, gmode, errorcode;
/* initialize graphics mode */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* return with error code */
}
/* draw a line */
line(0, 0, getmaxx(), getmaxy());
/* clean up */
getch();
closegraph();
return 0;
}
The Build log shows:
Process terminated with status 0 (0 minute(s), 1 second(s))
What is the problem here? Is there a possible solution for this error?
User contributions licensed under CC BY-SA 3.0