Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Using time in C++ application?

Reply
Thread Tools

Using time in C++ application?

 
 
Jonas Granqvist
Guest
Posts: n/a
 
      07-19-2003
I wonder if someone could help me with some sample code on how to make a
simple application using time. How can I for instance make the program
run the function "foobar()" every ten seconds? I've seen programs using
the time.h include file, is that the one to use?

Regards,
Jonas Granqvist

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-19-2003
"Jonas Granqvist" <(E-Mail Removed)> wrote...
> I wonder if someone could help me with some sample code on how to make a
> simple application using time. How can I for instance make the program
> run the function "foobar()" every ten seconds? I've seen programs using
> the time.h include file, is that the one to use?


Pseudocode:

1. Read system time (using time() function)
2. Calculate the value of what 'time' should return ten
seconds from now (using localtime() and mktime()
functions), assign it to 'future' variable
3. Call foobar()
4. Read system time.
5. If system time is the same as or greater than 'future',
go to 3. Otherwise go to 4.

Victor


 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-19-2003
"Victor Bazarov" <(E-Mail Removed)> wrote...
> "Jonas Granqvist" <(E-Mail Removed)> wrote...
> > I wonder if someone could help me with some sample code on how to make a
> > simple application using time. How can I for instance make the program
> > run the function "foobar()" every ten seconds? I've seen programs using
> > the time.h include file, is that the one to use?

>
> Pseudocode:
>
> 1. Read system time (using time() function)
> 2. Calculate the value of what 'time' should return ten
> seconds from now (using localtime() and mktime()
> functions), assign it to 'future' variable
> 3. Call foobar()
> 4. Read system time.
> 5. If system time is the same as or greater than 'future',
> go to 3. Otherwise go to 4.


Error. Should be

5. If system time is the same as or greater than 'future',
go to 1. Otherwise go to 4.

Victor


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is time.time() < time.time() always true? flamesrock Python 8 11-24-2006 06:51 AM
Re: interpreting the fractional portion of time.clock() vs time.time(0measurements Peter Hansen Python 0 02-22-2006 02:02 PM
Re: interpreting the fractional portion of time.clock() vs time.time()measurements Peter Hansen Python 0 02-22-2006 12:03 AM
time.clock() or time.time() peterbe@gmail.com Python 8 08-05-2005 01:51 PM
delta time = time stop - time start engsol Python 2 01-26-2004 12:06 PM



Advertisments