<graphics.h> header file not working in C or C++

When I declare the <graphics.h> header file in a C language file, Repl reports that it doesn’t exist. When I do the same in a C++ language file, Repl returns “Hello World.” in the console and does nothing else.

I had expected the <graphics.h> header file to work in C and C++. This did not happen, as you can see above.

The code I used for C++ is this:

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

void main()
{
int gd = DETECT, gm;
clrscr();
initgraph(&gd, &gm, “C:\TURBOC3\BGI”);

setcolor(BLUE);

rectangle(50,50,100,100);

getch();

closegraph();
}

The code I used for C is this:

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

This bug occurred on a Chromebook in the Chrome browser.

Thank you!

Hi @waveboi131 welcome to the community.

Can you please share a link to both the C and C++ Repls here?

1 Like

I suggest reading some of the posts here. graphics.h is a very old file, I don’t know that it’d be compatible with Linux (which is the machine that all Repls run on) (edit: I believe this file is for Windows, or at the very least, the ‘modern version’ is). Also, if you have not added the graphics.h file into your Repl (if you cannot see it with the rest of your files in the file hierarchy) then you have not added it to your Repl properly (and not all, even too many, header files are built-in and can just be accessed, you should mostly assume you have to manually add it yourself).