Hi
I`ve just started working with graphic in c++.I want to display a stack on the console . I taugth draw a rectangle as a stack.but the problem is I don know how to draw a rectangle!
I write some codes but my compiler (Dev-c++) couldn support them. I found out they are suitable with a DOS compiler. so plz tell me how to draw a rectangle! with what library function i should do that?
thanks

Recommended Answers

All 2 Replies

Hi
I`ve just started working with graphic in c++.I want to display a stack on the console . I taugth draw a rectangle as a stack.but the problem is I don know how to draw a rectangle!
I write some codes but my compiler (Dev-c++) couldn support them. I found out they are suitable with a DOS compiler. so plz tell me how to draw a rectangle! with what library function i should do that?
thanks

There are lots of threads on Daniweb regarding how to draw a rectangle/box on the console. Try the search engine. Here's one:

http://www.daniweb.com/forums/thread111291.html

Regarding DOS and Dev C++, unless there is some reason to use DOS, I don't see why you would want to. What operating system are you using? I think the only library you would need is iostream.

http://www.cplusplus.com/reference/iostream/

and you'll mostly only need the cout function and endl.

http://www.cplusplus.com/reference/iostream/cout.html
http://www.cplusplus.com/reference/iostream/manipulators/endl.html

This will draw a temporary rectangle on the console:

#define _WIN32_WINNT 0x0500
#include<windows.h>
#include<iostream>

int main() {
	HWND console = GetConsoleWindow();
	HDC dc = GetDC(console);
	Rectangle(dc, 50, 50, 100, 100);
	ReleaseDC(console, dc);
	std::cin.ignore();
	return 0;
}
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.