Author Topic: time.h  (Read 4488 times)

0 Members and 1 Guest are viewing this topic.

Offline iloveks

  • NULL
  • Posts: 1
  • Cookies: 0
    • View Profile
time.h
« on: December 17, 2012, 07:17:31 pm »
Hi i wants to know how to use time.h
i waana to use it for making a c++ game which has 30 sec deadline so how should i use it.

Offline geXXos

  • Royal Highness
  • ****
  • Posts: 646
  • Cookies: 178
    • View Profile
Re: time.h
« Reply #1 on: December 17, 2012, 07:19:56 pm »
http://www.cplusplus.com/reference/ctime/

Welcome at EZ

Edit*

@iloveks
 
What this poll is about, which one is better in what ? more easy? develop apps,games,general programming ? with which one to start ?

They are all C to me.

Anyway i vote for "C" having in mind the fact that all the others are easier to get later.
« Last Edit: December 17, 2012, 07:34:30 pm by geXXos »

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: time.h
« Reply #2 on: December 17, 2012, 09:44:32 pm »
Pole unrelated. Removed.
Try this.

Offline Xires

  • Noob Eater
  • Administrator
  • Knight
  • *
  • Posts: 379
  • Cookies: 149
    • View Profile
    • Feed The Trolls - Xires
Re: time.h
« Reply #3 on: December 19, 2012, 03:17:14 am »
man time.h

The basic idea, for creating a timer, is to create something to store the time.  Typically this is a struct of type 'time_t'.  You then grab the current time via a call to 'time()', usually passing NULL as the argument.  All of this is done before you begin a timer loop.  The timer loop is relatively easy as well; just keep a temporary copy of the current time that you update continuously.  When you've reached the time limit(meaning your first saved time & your current time are 30 seconds apart, in this case), you end the timer loop.

There are some better methods as well, such as actually using an alarm, or setting a system timer, etc.

Good luck.
-Xires