#include <windows.h>
#include <iostream>
#include <ctime>
using namespace std;
void cls()
{
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
if (!GetConsoleScreenBufferInfo(hConsole, &csbi))
return;
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
if (!FillConsoleOutputCharacter(hConsole, (TCHAR)' ', dwConSize, coordScreen, &cCharsWritten ))
return;
if (!GetConsoleScreenBufferInfo( hConsole, &csbi ))
return;
if (!FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten ))
return;
SetConsoleCursorPosition( hConsole, coordScreen );
}
void resetCursorPosition()
{
COORD coordScreen = { 0, 0 };
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition( hConsole, coordScreen );
}
const int c_fontHeight = 5;
const int c_charCounr = 11;
const char* font[c_charCounr][c_fontHeight] =
{
{
"*** ",
"* * ",
"* * ",
"* * ",
"*** ",
},
{
"** ",
" * ",
" * ",
" * ",
"*** ",
},
{
"*** ",
" * ",
"*** ",
"* ",
"*** ",
},
{
"*** ",
" * ",
"*** ",
" * ",
"*** ",
},
{
"* * ",
"* * ",
"*** ",
" * ",
" * ",
},
{
"*** ",
"* ",
"*** ",
" * ",
"*** ",
},
{
"*** ",
"* ",
"*** ",
"* * ",
"*** ",
},
{
"*** ",
" * ",
" * ",
" * ",
" * ",
},
{
"*** ",
"* * ",
"*** ",
"* * ",
"*** ",
},
{
"*** ",
"* * ",
"*** ",
" * ",
"*** ",
},
{
" ",
"* ",
" ",
"* ",
" ",
},
};
void drawLine(int line, const char* buffer)
{
for(int i = 0; buffer[i]; i++)
{
int index = buffer[i] - '0';
cout << font[index][line];
}
cout << endl;
}
int main(int argc, char* argv[])
{
time_t rawtime;
tm* timeinfo;
char buffer[32];
cls();
while(1)
{
rawtime = time(0);
timeinfo = localtime(&rawtime);
strftime(buffer, sizeof(buffer), "%H:%M:%S", timeinfo);
for(int line = 0; line < c_fontHeight; line++)
{
drawLine(line, buffer);
}
resetCursorPosition();
}
return 0;
}