I can not run this program in my C++ compiler(Dev c++).

#include <iostream.h>
#include <conio.h>
#include <graphics.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>

int main()
 // clrscr();
  int gd = DETECT,gm,errorcode; //Requesting auto-detection.

  //Initializing graphics and local variables.
  initgraph (&gd, &gm, "d:\\bc3\\bgi"); //Path where graphics drivers are installed

  //Read result of initialization.
  errorcode = graphresult();

  //An error occured.
  if (errorcode != grOk)
      cout << "Graphics error occured : \n" << grapherrormsg(errorcode) << endl;
      cout << "Press any key to stop : ";

  /*Drawing a rectangle having top LHS vertex at (300, 300)
  and bottom RHS vertex at (600, 400)*/
  rectangle(300, 300, 600, 400);
  rectangle(100, 100, 200, 200);
  floodfill(120, 120, WHITE);
	return 0;

The errors are

  • \rectangle.cpp E:\E graphics.h: No such file or directory.
  • 32:2 C:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
  • 1 C:\Dev-Cpp\include\c++\3.4.2\backward\iostream.h:31, from E:\rectangle.cpp In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31, from E:\rectangle.cpp
  • 11 E:\rectangle.cpp `DETECT' undeclared (first use this function)
  1. 17 E:\rectangle.cpp `graphresult' undeclared (first use this function)

Please help.

That's because none of the graphics you are using is part of Dev-C++. That's the old (very old) Borland compiler.

WaltP, Thanks for your reply.
Then how can I will run graphics program in c++.
Any recommanded compiler?
Please say.

I don't do graphics. But you can search the forums. It has been answered many times.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.