here is a working function in a program that demonstrates that it works.. now you'll have to mess around with it to get it to be just golden (i'm so funny) and how you like it. (you'll have to tweak some of it to how you like)
Code:
#include <iostream.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#include <conio.c>
void printBox(int width, int height);
COORD xyToCoord(int x, int y);
int main()
{
int height, width;
cout << "input height" << endl;
cin >> height;
cout << "input width" << endl;
cin >> width;
clrscr();
printBox(width, height);
system("PAUSE");
return 0;
}
COORD xyToCoord(int x, int y)
{
COORD outputCoord = {x, y};
return outputCoord;
}
void printBox(int width, int height)
{
HANDLE hOutput;
hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
if (height == width)
{
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
if (y == 0 || y == (width - 1) || x == 0 || x == (height - 1))
{
SetConsoleCursorPosition(hOutput, xyToCoord(x, y));
cout << "|";
}
else
{ cout << ".";}
/*else if (x == 0 || x == (height))
{
SetConsoleCursorPosition(hOutput, xyToCoord(x, y));
cout << "|";
} */
}
}
}
else if (width > height)
{
for (int y = 0; y < width; y++)
{
for (int x = 0; x < width; x++)
{
if (y == 0 || y == (width -1))
{
SetConsoleCursorPosition(hOutput, xyToCoord(x, y));
cout << "|";
}
else if (x == 0 || x == (height))
{
SetConsoleCursorPosition(hOutput, xyToCoord(x, y));
cout << "|";
}
}
}
}
else if (height > width)
{
for (int y = 0; y < height; y++)
{
for (int x = 0; x < height; x++)
{
if (y == 0 || y == (width))
{
SetConsoleCursorPosition(hOutput, xyToCoord(x, y));
cout << "|";
}
else if (x == 0 || x == (height - 1))
{
SetConsoleCursorPosition(hOutput, xyToCoord(x, y));
cout << "|";
}
}
}
}
}
(this works on my comp, i don't know if it will work on yours)