Man kunne også kaste sig ud i noget i stil med:
#include <iostream>
#include <windows.h>
HANDLE StdOut = GetStdHandle(STD_OUTPUT_HANDLE);
void GotoXY(int x, int y)
{
COORD c;
c.X = (short )x;
c.Y = (short )y;
SetConsoleCursorPosition(StdOut, c);
}
template<typename T>
void PutXy(int x, int y, T t)
{
GotoXY(x, y);
std::cout << t;
std::cout.flush();
}
void ClearScreen()
{
short i;
CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo;
GetConsoleScreenBufferInfo(StdOut, &ConsoleScreenBufferInfo);
SMALL_RECT Pos = ConsoleScreenBufferInfo.srWindow;
DWORD D;
for(i = Pos.Top; i <= Pos.Bottom; i++)
{
COORD C;
C.X = Pos.Left;
C.Y = i;
FillConsoleOutputCharacter(StdOut, ' ', Pos.Right - Pos.Left, C, &D);
FillConsoleOutputAttribute(StdOut, 0, Pos.Right - Pos.Left, C, &D);
}
GotoXY(0, 0);
}
int GetMaxX()
{
CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo;
GetConsoleScreenBufferInfo(StdOut, &ConsoleScreenBufferInfo);
SMALL_RECT Pos = ConsoleScreenBufferInfo.srWindow;
return Pos.Right;
}
int GetMaxY()
{
CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo;
GetConsoleScreenBufferInfo(StdOut, &ConsoleScreenBufferInfo);
SMALL_RECT Pos = ConsoleScreenBufferInfo.srWindow;
return Pos.Bottom;
}
int main()
{
ClearScreen();
int maxX = GetMaxX();
int maxY = GetMaxY();
int midX = GetMaxX()/2;
int midY = GetMaxY()/2;
for(int x = 0; x < maxX - 2; x++)
PutXy(x, midY, '-');
for(int y = 0; y < maxY - 2; y++)
PutXy(midX, y, '|');
// Throw in some random points:
PutXy(midX + 10, midY + 10, "*");
PutXy(midX - 10, midY + 10, "*");
PutXy(midX - 10, midY - 10, "*");
std::cin.get();
}