Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,423 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,967 people online right now. Registration is fast and FREE... Join Now!




time function

 
Reply to this topicStart new topic

time function

ihcs50
13 Jan, 2008 - 09:22 AM
Post #1

New D.I.C Head
*

Joined: 2 Jan, 2008
Posts: 8

I am making a game in C where I need a function that waits a certain amount of time and if an action hasn't occurred in that amount of time, another action occurs. Does anyone have any suggestions on what to use?

This is what I need to happen:

if in n seconds (!box_clicked) then action;

This post has been edited by ihcs50: 13 Jan, 2008 - 09:29 AM
User is offlineProfile CardPM
+Quote Post

chellappa
RE: Time Function
13 Jan, 2008 - 09:55 AM
Post #2

New D.I.C Head
*

Joined: 13 Jan, 2008
Posts: 2

QUOTE(ihcs50 @ 13 Jan, 2008 - 10:22 AM) *

I am making a game in C where I need a function that waits a certain amount of time and if an action hasn't occurred in that amount of time, another action occurs. Does anyone have any suggestions on what to use?

This is what I need to happen:

if in n seconds (!box_clicked) then action;

please use kbhit() function .If !kbhit() in specified time give command for the next action destired.
kbhit means key boardhit .It is in conio.h
time(NULL) to note time from system clock
time _t t1,t2,diff;

User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Time Function
13 Jan, 2008 - 10:10 AM
Post #3

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,260



Thanked: 227 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
I just wanted to note that kbhit is not part of the ANSI standard and so make sure that your compiler supports it before completely relying on it. smile.gif
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 04:31AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month