#include "g:\victor\vitodef.h"

//prototypes

void printchar(char);
void skiplines(int);
void drawline(int, char);
void drawblanks(int);
void drawrec(int, int, char);
void drawbox(int, int, char);


// function definitions

void printchar(char ch)
// prints character ch
{
cprintf("%c",ch);
}

void skiplines(int howmany)
// goes to new line howmany times
{
for (; howmany > 0; howmany--)
	cout << endl;
}

void drawline(int len, char c)
// prints line of len characters c
{
while (len > 0)
	{
	printchar(c);
	len--;
	}
}

void drawblanks(int number)
// prints number blank spaces
{
drawline(number, ' ');
}


void drawrec(int high, int wide, char symbol)
// draws rectangle hidh * wide of character symbol
{
while (high > 0)
	 {
	 drawline(wide, symbol);
	 skiplines(1);
	 high--;
	 }
}


void drawbox(int high, int wide, char mark)
// draws hollow rectangle high * wide of character MARK
{
drawline(wide, mark);
skiplines(1);
for (high--; high > 1; high--)
	{
	printchar(mark);
	drawblanks(wide-2);
	printchar(mark);
	skiplines(1);
	}
drawline(wide, mark);
skiplines(1);
}

void main(void)
// tests all functions; outputs a rectangle and a box
// user is asked for dimensions and character
{
int height, width;
char letter;
clrscr();
textcolor(YELLOW);            // use any common color name
textbackground(RED);
cout << "enter height and width of your shape\n";
cout << "limits 20 * 79\n";
cin >> height >> width;
cout << "enter a character to use\n";
cin >> letter;
clrscr();
drawrec(height, width, letter);
wait;
clrscr();
drawbox(height, width, letter);
getch();
}



