delay() or sleep()

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2008
Posts: 44
Reputation: rje7 is an unknown quantity at this point 
Solved Threads: 3
rje7 rje7 is offline Offline
Light Poster

delay() or sleep()

 
0
  #1
Apr 11th, 2008
in turbo C++ there is a function called delay(); and in microsoft compiler i guess it is sleep or msleep. what could be the possible equivalent function which can be used when compiling in GCC.

using the looping technique will give different time difference in different machines. is it true?

also i would like to know how to change the text colors.
the turbo c++ offers setcolor/textcolor function. what is the equivalent of it in the GCC.
Last edited by rje7; Apr 11th, 2008 at 2:02 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: delay() or sleep()

 
0
  #2
Apr 11th, 2008
>what could be the possible equivalent function which can be used when compiling in GCC

I guess you could use something from the <ctime> library

Not sure about the colour bit. Using the cursors library maybe?
Last edited by iamthwee; Apr 11th, 2008 at 4:46 am.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,983
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 308
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is online now Online
Cenosillicaphobiac

Re: delay() or sleep()

 
1
  #3
Apr 11th, 2008
If using windows: Click
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 275
Reputation: dougy83 is on a distinguished road 
Solved Threads: 45
dougy83 dougy83 is offline Offline
Posting Whiz in Training

Re: delay() or sleep()

 
0
  #4
Apr 11th, 2008
For microsoft windows, the Sleep and SleepEx functions provide delays.

In Linux you can use the usleep function.

I don't know any GCC-specific delay command, nor any portable delay command. If you want to make it portable, you might have to roll your own, or use condition compilation to use a different OS delay function depending on the OS used.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 44
Reputation: rje7 is an unknown quantity at this point 
Solved Threads: 3
rje7 rje7 is offline Offline
Light Poster

Re: delay() or sleep()

 
0
  #5
Apr 12th, 2008
Originally Posted by dougy83 View Post
For microsoft windows, the Sleep and SleepEx functions provide delays.

In Linux you can use the usleep function.

I don't know any GCC-specific delay command, nor any portable delay command. If you want to make it portable, you might have to roll your own, or use condition compilation to use a different OS delay function depending on the OS used.
which header files should i include?
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 44
Reputation: rje7 is an unknown quantity at this point 
Solved Threads: 3
rje7 rje7 is offline Offline
Light Poster

Re: delay() or sleep()

 
0
  #6
Apr 12th, 2008
Originally Posted by niek_e View Post
If using windows: Click
thank you
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 16756 | Replies: 5
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC