Anyway...for a hollow box, try...
#include <iomanip>
...
cout<<"|"<<setw(width-2)<<"|"<<endl;
setw() sets a certain amount of blank spaces.
Anyway, try this instead:
Code:
/*code with filled spaces*/
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
char character;
int width =79,
height = 20;
cout << "enter the character, width and height (eg. * 6 3";
cin >> character >> width >> height;
if(width > 79 || height > 20)
{
cout<<"ERROR: Not a valid width/height pair!"<<endl;
return 0;
}
for (int i = 0; i < height; i++)
{
for (int j = 0; j <width; j++)
cout<< character;
cout<<endl;
}
return 0;
}
Code:
/*using setw()*/
#include <iostream>
#include <iomanip>
using std::cout;
using std::cin;
using std::endl;
using std::setw;
int main()
{
char character;
int width,
height;
cout << "enter the character, width and height (eg. * 6 3";
cin >> character >> width >> height;
if(width > 79 || height > 20)
{
cout<<"ERROR: Not a valid width/height pair!"<<endl;
return 0;
}
for(int x=0; x<width; x++)
cout<<character;
cout<<endl;
for (int i = 0; i < height-2; i++)
cout<<character<<setw(width-1)<<character<<endl;
for(int j=0; j<width; j++)
cout<<character;
cout<<endl;
return 0;
}