C++ -> Drawing Rectangles to Console






2.63/5 (4 votes)
Smaller code:void DrawRect(int x, int y, int width, int height, int curPosX=0, int curPosY=0){ setxy(x, y); cout << char(201); cout.width(width); cout.fill (char(205)); cout << char(187); setxy(x,height+y); cout << char(200); cout.width(width); cout.fill...
Smaller code:
void DrawRect(int x, int y, int width, int height, int curPosX=0, int curPosY=0) { setxy(x, y); cout << char(201); cout.width(width); cout.fill (char(205)); cout << char(187); setxy(x,height+y); cout << char(200); cout.width(width); cout.fill (char(205)); cout << char(188); for(int i = y + 1; i < height+y; i++) { setxy(x,i);cout << char(186); setxy(x + width,i);cout << char(186); } setxy(curPosX,curPosY); }Using ostream::width() and ostream::fill() functions.