Mustafa Noman
Mustafa Noman

Reputation: 13

Unable to use graphic.h in c++ in visual studio

Okay so I needed to create a project in c++ which involves using multiples straight lines in the output.So I searched through everything and thought of using graphic.h. But it doesn't work in Visual Studio 2019 so I somehow downloaded graphic.h but i'm still not able to run my program for idk what reasons. So is there an easy way to do this?I just need to have a bunch of straight lines and maybe a little bit of color too.

Upvotes: 0

Views: 21090

Answers (2)

Anh Huynh
Anh Huynh

Reputation: 109

Actually you can use graphics.h on the lastest version of Visual Studio

  1. Download graphics.h and graphics.lib files in https://github.com/ahuynh359/Graphics
  2. Drag these two files and drop to your sub project. For example if my project named Project1 I will add these two files to Project1\Project1 enter image description here
  3. Right click on the project choose Properties choose Configuration Manager change to x86 and Win32 enter image description here enter image description here
  4. Implement these code
#include "graphics.h"
#pragma comment(lib,"graphics.lib")
int main()
{
    initwindow(500, 500);
    getch();
    closegraph();
    return 0;
}

Upvotes: 0

Jesper Juhl
Jesper Juhl

Reputation: 31447

graphics.h is a non-standard header that's only available with the Turbo C / Turbo C++ compilers from Borland. Those products have been obsolete for ~25 years and should not be used today.

In addition, any code that uses graphics.h will only work on old DOS systems (and old windows systems that ran on top of DOS or included a DOS subsystem). Modern Linux and Windows systems won't work with code based on graphics h

You should switch to a more modern graphics library like SFML or SDL or a number of other options. Learning / using graphics.h in 2020 is just wasting your time - noone uses that any more and it doesn't even work on modern systems.

Upvotes: 6

Related Questions