C++/Error in program
Expert: vijayan - 1/3/2012
QuestionHi Sir,
I use Turbo C++ v4.5 on Windows Vista. The below-mentioned program always gives an error "Error directive: BGI graphics not supported under Windows.". What can I do to overcome the problem?
This is the source 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;
}
Thanking you,
Yours' faithfully,
Aashish
Answer1. Switch to a more current compiler suite and IDE - for example, CodeBlocks+MinGw
http://prdownload.berlios.de/codeblocks/codeblocks-10.05mingw-setup.exe
2. Use a currently supported gui library - for example, WxWidgets
http://www.wxwidgets.org/