-
Using the sleep function
I'm trying to use the sleep function for a program that simulates a traffic light. But when i use the function it delays the start of the program not between where i have printed light green and light yellow to the screen where i want it.
I have placed it between the two cout statements and it still delays the beginning of the program which makes no sense.
Anyone got any ideas?
-
Post your complete code. Don't forget to use code tags (instructions on how to use them are at the top of the C++ board.
-
Perhaps you need to flush your first console output. Otherwise the system may buffer it:
Code:
cout << "Light green." << flush;
Or you can add a endl which will output a newline and flush the buffer:
Code:
cout << "Light green." << endl;
-
Thanx
Thanks Swoopy that worked all it needed was a flush. Thanks for the help.