Ok, I compiled this on MS-Notepad, so it's VERY likely that there are errors etc. Anyways, here goes.
Code:
#include <iostream>
#include <windows.h>
using namespace std;
void GotoXY ( int X, int Y )
{
COORD Cursor_Position;
Cursor_Position.X = X;
Cursor_Position.Y = Y;
SetConsoleCursorPosition( GetStdHandle ( STD_OUTPUT_HANDLE ), Cursor_Position );
}
void FindXY( int &X, int &Y )
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(stdOut, &csbi);
X = csbi.dwCursorPosition.X;
Y = csbi.dwCursorPosition.Y;
}
int main()
{
char d[9], t[9]; // Whoops, forgot these
int x, y;
for(;;)
{
if( kbhit() )
{
cout<< 'X';
Sleep( 100 ); // So the screen won'e be filled with X
}
else
{
FindXY( x, y );
GotoXY( 0, 0 );
cout<< " \r"; // May need to add more. I dunno.
_strdate(d);
_strtime(t);
cout << "Date: " << d << ", "
<< "Time: " << t;
GotoXY( x, y );
}
}
return(0);
}
EDIT: there may be a need for conio for kbhit(), I can't remember.