2

I am trying to run "line program" in graphics using C++ in Code Blocks. I had already done setting up the environment in code blocks for graphics. Still I am getting the problem in this program. The program shows no error , but when I run it , it doesn't show any line in output . Output my program is showing. Here is my code:

#include <graphics.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{

int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"c:\\MinGW\\include\");
setcolor(4);
line(30,100,210,100);
line(30,101,210,101);
getch();
}
genpfault
  • 51,148
  • 11
  • 85
  • 139
FILZA Tariq
  • 31
  • 1
  • 4
  • graghics.h not working in code blocks always but I don't think that you can do something to able this. try using turbo c++. – Roy Avidan Mar 19 '17 at 21:03
  • 2
    Possible duplicate of [How to use graphics.h in codeblocks?](http://stackoverflow.com/questions/20313534/how-to-use-graphics-h-in-codeblocks) – wally Mar 19 '17 at 21:18
  • 1
    are you running in MS-DOS? if not than it will not work as `graphics.h` is the ancient Borland BGI lib. There are also emulators like WinBGI which could work on windows (not sure if x64).... anyway if you really want to make this work you need to set your compiler to target 16 bit MS-DOS platform and run the exe in emulator like DosBox or real MS-DOS ... – Spektre Mar 20 '17 at 08:04
  • 1
    Possible duplicate of [What can I do if code::blocks shows error when I try to use graphics.h for c/c++?](https://stackoverflow.com/questions/43958082/what-can-i-do-if-codeblocks-shows-error-when-i-try-to-use-graphics-h-for-c-c) – Mukesh M Sep 19 '17 at 12:39

1 Answers1

0

Change the location of bgi

PUT THIS:

initgraph(&gdriver,&gmode,"..\\bgi\\");
cany
  • 39
  • 7