Click here to Skip to main content
15,567,482 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to check one condition for every one seconds in C?

if(i>1000)
{
printf("");
}

this is the condition.. How to do it?
Posted
Comments
Sergey Alexandrovich Kryukov 15-Nov-13 3:41am    
Why? And what is "i" and why do you think it may change? In different thread? So far, the question makes little sense, if any at all.
—SA
super 15-Nov-13 6:29am    
You dont need to know what or why "i" does. He just wants to execute this method/function every one second
Sergey Alexandrovich Kryukov 15-Nov-13 10:19am    
You don't understand. 1) This is not a method, 2) it does nothing except wasting CPU time, 3) what it does depends on "i".
Everything here just makes little to no sense.
—SA
Purevochir 11-Dec-13 3:42am    
I is packet number

Check C++ sleep for milliseconds[^] for answers depending on various OSs and/or compilers.
For Visual C++ the function you want is Sleep (included in windows.h)

P.S.: for Ubuntu Linux it should be sleep() (lowercase s) and should be included in unistd.h. see http://ubuntuforums.org/showthread.php?t=296142[^]
 
Share this answer
 
v2
use
delay(1000);


to delay for desired seconds and then use your condition
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900