954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

drawing a rectangle!

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

3pid
Newbie Poster
17 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 
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

VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
 

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;
}
William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You