0

From this tutorial site, I ran this code below as .c file,

#include<graphics.h>
#include<stdio.h>
#include<conio.h>

void main(void) {
    int gdriver = DETECT, gmode;
    int x1 = 200, y1 = 200;
    int x2 = 300, y2 = 300;
    clrscr();

    initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi");
    line(x1, y1, x2, y2);
    getch();
    closegraph();
}

Unfortunately, I got this error

[Error] sstream: No such file or directory

From this site, I saved the code in .cpp file and I ran it successfully without any error. However, no graphic drawing shows, its only the command prompt that appears. This link did not work either. Please, is there any workaround to make it work.

Note: I use TDM-GCC 4.9.2 64-bit Release

genpfault
  • 51,148
  • 11
  • 85
  • 139
Anas
  • 125
  • 13
  • 4
    This example program is for the ancient, prehistoric Turbo C++ compiler (which is even older than your gcc 4.9.2 compiler), did you read that part of the web site whose link you've provided? It is fairly likely that you don't even have the `C:\TurboC3\BGI` directory that your code references. The shown information and material has been outdated and obsoleted for many decades. You should also update your compiler too, in any case, as gcc 4.9 does not implement the current C++ standard. – Sam Varshavchik Jun 28 '21 at 01:32
  • Thanks for your comment. Please can you help me reproduce similar code to match the current C++ standard. I am new to C and C+graphics programming. or can u direct me to where I can follow from scratch. Almost the sites i follow to learn C or C++ graphic programing are using the obsolate codes! – Anas Jun 28 '21 at 12:34
  • Stackoverflow [has a list of current up to date C++ textbooks](https://stackoverflow.com/questions/388242/) which is where you start if you want to learn C++ from scratch. As you've discovered, you cannot learn C++ from some web site or a Youtube video, but only from an edited textbook. There's a lot to learn about C++ basics, before getting into specialized topics like graphics. You cannot realistically expect to learn how to use graphics in C++ without fully and completely understanding C++ core topics: inheritance, polymorphism, overloading, templates, and many others. – Sam Varshavchik Jun 28 '21 at 12:51

0 Answers0