Using the simple iostream.h stuff like cout << "blah"; , I want to make a message appear every 350 milliseconds. How would I do that?
Using the simple iostream.h stuff like cout << "blah"; , I want to make a message appear every 350 milliseconds. How would I do that?
Use sleep().
-----
for (;;
{
cout << "blah" << endl;
sleep(350);
}
-----
Kuphryn
1. sleep is undeclared identifier.
2. does it put the entire program on hold?
#include <afxwin.h>
Yes, I believe sleep() will halt the enter program.
Kuphryn
>sleep is undeclared identifier.
So write it yourself.
>does it put the entire program on hold?Code:#include <ctime> void sleep ( long m ) { clock_t limit, cl = clock(); limit = cl + m; while ( limit > cl ) cl = clock(); }
This is implementation specific. One implementation may write a sleep or delay function which is thread friendly and another may not. The code I gave above is not, but you can write code which gives the feeling of synchonization through use of time-sharing.
-Prelude
My best code is written with the delete key.
is this a dos program? you don't have events in dos. how are you going to continue doing other stuff while you wait for a timer to fire? Maybe I'm confused. probably.