timer..(again) (newbie inside)
I have this little programm here, it supposed to write "second" everysecond on the screen, but it doesn''t, so what do i wrong?
#include
#include
bool done=true;
void main()
{
time_t CompareTime;
const NumberOfSecondsBetween = 1;
//
time(&CompareTime);
//
do
{
if (time(NULL) >= CompareTime + NumberOfSecondsBetween)
{
cout << "second ";
time(&CompareTime);
};
}
while(done);
};
u wouldnt understand a german quote :)
includes are iostream.h and time.h, wish i knew how to write those code pages on the forums....
int main(int argc, char *argv[])
{
long target_time, wait_time = 1;
for(int i = 0;i < 10; i++)
{
target_time = time(NULL) + wait_time;
while(time(NULL) < target_time)
{
//do nothing until wait_time has passed
}
cout << "second ";
}
return 0;
}
wow, non-sloppy code. i should do that more often
Edited by - GumpusPMaximus on November 14, 2000 11:07:10 AM
int main(int argc, char *argv[])
{
long target_time, wait_time = 1;
for(int i = 0;i < 10; i++)
{
target_time = time(NULL) + wait_time;
while(time(NULL) < target_time)
{
//do nothing until wait_time has passed
}
cout << "second ";
}
return 0;
}
wow, non-sloppy code. i should do that more often
Edited by - GumpusPMaximus on November 14, 2000 11:07:10 AM
~Gumpus P. Maximus~
You mean like :
????
Just do an edit of this note.
cout << "test stuff" << endl;
????
Just do an edit of this note.
-----------------------------------------------All messages are of my own personal opinion and not meant to offend. But if they do - tough :)Neuro.
i wrote this code:
but it doesn''t print anything
(its a win32 console application
#include <iostream.h>#include <time.h>int main(int argc, char *argv[]){long target_time, wait_time = 1;for(int i = 0;i < 10; i++){target_time = time(NULL) + wait_time;while(time(NULL) < target_time){//do nothing until wait_time has passed}cout << "second ";}return 0;}
but it doesn''t print anything
(its a win32 console application
u wouldnt understand a german quote :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement