954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Sleep method nad System time

hi,

i am having a project where i must implement a method that takes measurements(random numbers) on specific time intervals.This means that i should read (for example) a number every 5minites...I ve been told for a sleep function but i can't find any info about it....Any thoughts on how i should implement this method?:confused:

also is there any way to read the system time through c++?{to know what time appears in the system clock}

thanks in advance for your help....:)
Nicolas

n.aggel
Posting Whiz in Training
203 posts since Nov 2006
Reputation Points: 23
Solved Threads: 12
 
I ve been told for a sleep function but i can't find any info about it....Any thoughts on how i should implement this method?


If you are using Linux, then this for sleep and if you are using windows then this .
also is there any way to read the system time through c++?{to know what time appears in the system clock} Yes there is, use the header file#include if using C++ or #include if using C. For the header reference see here and here .
thanks in advance for your help....Nicolas
Glad we could help.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

so i shoud implement that function as thread?{In order to call the sleep function on that thread....}

n.aggel
Posting Whiz in Training
203 posts since Nov 2006
Reputation Points: 23
Solved Threads: 12
 

No need to complicate matters, here is a simple way of using the function..

#include <iostream>
#include <windows.h>
using namespace std;
 
int main(int argc, char** argv)
{
    cout << "Hello" << endl ;
    cout << "Wait for 3 seconds..." << endl ;
    Sleep(5000) ; // takes the time in milliseconds ( 1 second = 1000 milliseconds)
    cout << "World" ;
    getchar( ) ;
    return 0 ;
}
~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

thanks alot!

n.aggel
Posting Whiz in Training
203 posts since Nov 2006
Reputation Points: 23
Solved Threads: 12
 

Thanks I just found this through google great help

HLA91
Junior Poster
177 posts since Oct 2006
Reputation Points: 7
Solved Threads: 3
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You