Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sleep()

Status
Not open for further replies.

ddnh

Programmer
Nov 25, 2002
94
US
I'm trying to find out why the program doesn't sleep for 2 seconds after the first cout.

#include <iostream.h>
#include <windows.h>

main()
{
cout << &quot;blah\n&quot;;
Sleep(2000);
cout << &quot;blah\n&quot;;
return 0;
}
 
cout << &quot;blah\n&quot;; only push the text on the screen buffer but don't force the cpu to draw it to the screen... That's why you're into the impression that the program waits for 2 seconds and then draw the text... It's in fact the end of the program that force the drawing.

Use
cout << &quot;blah&quot; << endl;

endl will force the cpu to draw the text...

hope this will help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top