C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old April 28th, 2002, 02:15 PM
Bisifiniti Bisifiniti is offline
The Bisifiniti
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 25 Bisifiniti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Bisifiniti
Causing a delay in milliseconds

How do I cause the program to stop running for X amount of milliseconds?

Example,

for(i=1;1<10;i++){
printf("%i\n",i);
function_causes_100ms_wait;
}

Basically, I need a function that can pause the program. Couldn't find anything on Google or any books I have lying around.
__________________

Reply With Quote
  #2  
Old April 29th, 2002, 02:11 AM
jonsagara's Avatar
jonsagara jonsagara is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: USA
Posts: 286 jonsagara User rank is Private First Class (20 - 50 Reputation Level)jonsagara User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 m 23 sec
Reputation Power: 7
What platform are you programming on? I know that Sleep(...) works on Windows platforms.

I'm sure there is a similar function for Unix, but I don't know what headers (if any) you would need to include.
__________________
Jon Sagara

"Me fail English? That's unpossible!"

Reply With Quote
  #3  
Old April 29th, 2002, 02:17 PM
CodeBastard CodeBastard is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Location: Sweden
Posts: 0 CodeBastard User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to CodeBastard
If you are using unix, the function you're looking for is usleep, from unistd.h
usleep suspends execution for X microseconds.

Code:
for(i=1;1<10;i++){ 
    printf("%i\n",i); 
    usleep(100000);
} 

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Causing a delay in milliseconds


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway