Hi!
I have a problem with graphics in c++.
It is a simple program, that displays circle.

#include "stdafx.h"
#include "iostream"
#include "graphics.h"
#include <cstdlib>
void main()
{
	int gdriver = 9;
	int gmode = 2;
	initgraph(&gdriver,&gmode,"");
	setbkcolor(WHITE);
	setcolor(BLACK);
	cleardevice();
	circle(320,240,180);
	getch();
	closegraph();

}

In visual studio i have error: error C2086: 'int right'
In Dev-C++ i have several errors:
[Linker error] undefined reference to `initgraph'
[Linker error] undefined reference to `setbkcolor'
[Linker error] undefined reference to `setcolor'
etc

I had to download some graphic libraries (graphics.h, winbgim.h), and copy it in include folder.
Can somebody tell me what's wrong with this?

Thanks!!!

Recommended Answers

All 2 Replies

The functions in graphics.h are only supported by old ancient Turbo C and Turbo C++ compilers. Those functions can not be used by any modern 32-bit compiler. You can either get a copy of that old MS-DOS compiler or use win32 api GDI functions or get one of several graphics libraries such as OpenGL and QT.

Tnx

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.