This prints the hour and waits 1 second before clearing the screen and printing it again. However, if I translate the printf statement to cout:
cout<<asctime(localtime(&t);
It sometimes prints intermitently, or sometimes it doesn't even bother to print. Why is this, can I avoid it (using cout of course)?
I'm using VC++6 on a XP machine

The difference between printf and cout is that cout is a buffered stream. Programmers use buffered streams because they allow multiple pieces of data to be read from an input device / written to an output device at once, instead of having to access the I/O device every time. The buffer stores, in memory, the data from a particular device. The problem with this is that if the data from the device changes, the buffer won't necessarily reflect that. Buffered streams have to be refreshed, or 'flushed', to update the buffer with the new data.

basically, cout.flush() and endl will output or flush the buffer to the console or output stream. therefore, if within your code, you don't have any line that contains the cout.flush() or the cout << endl, the buffer will just keep appending the output, without flushing it out to the screen.
for example, if you put a line 'cout << endl;' inside one of your if-statement (within the while loop, let say the statement that check for VK_ESCAPE), and press the escape key after some time (let say 10 seconds later), you will see 10 lines of output.

Templates For Beginners
Or
How To Encourage The Compiler To Work For You
Introduction
This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method. These are sometimes called "smart fields" because you can add logic that is applied automaticall…