You are here:

C++/Error in program

Advertisement


Question
Hi 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

Answer
1. 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/

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


vijayan

Expertise

my primary areas of interest are generic and template metaprogramming, STL, algorithms, design patterns and c++11. i would not answer questions about gui and web programming.

Experience

about 15 years or so

Education/Credentials
post graduate engineer

©2016 About.com. All rights reserved.