Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 26th, 2006, 8:04 AM   #1
hbe02
Hobbyist Programmer
 
hbe02's Avatar
 
Join Date: Mar 2006
Location: Lebanon
Posts: 148
Rep Power: 3 hbe02 is on a distinguished road
Delay using ctime

this is a delay function i wrote:
bool Delay(int delaytime) {
	int time1 = time(0);
	int time2 = time(0);
	while(time2-time1 < delaytime )
	{time2 = time(0);	}
	return true ;
}

this creates a delay of an integer amount in seconds. is it possible to create a delay in 100ms or 1.5 seconds? time(0) never returns a decimal number, only whole numbers
hbe02 is offline   Reply With Quote
Old Apr 26th, 2006, 10:31 AM   #2
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Good search doggy.

Edit: Note that it has been mentioned many times that it will not be exact as Windows or Unix (or mainstream OS) is not realtime. If you want to know more, use the searchterm "real time".
Like here.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:45 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC