Thread: Sleep...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    9

    Question Sleep...

    In <windows.h>
    there is a function called "Sleep()"

    can you tell me the definetion of this?

    why does it not work when it's small "sleep()"...

    Thanks...

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Sleep(int MilliSeconds) is a windows.h function that halts execution of the program for a set amount of milliseconds. There is another function sleep(int seconds) which lies in stdlib.h (I think, may be wrong though) which does the same but the argument is in seconds rather than milliseconds.

    why does it not work when it's small "sleep()"...
    C/C++ is case sensitive. Small or captial letters matter.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Sleep()

    Lowercase "sleep()" is POSIX and standard C (C99) and is in <unistd.h>. It's not in the Microsoft C-lib however.

    gg

  4. #4
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    BTW to convert millseconds to seconds just divide by 1000.



    Edit-----------------------------------------
    Read lower post.
    Last edited by CheesyMoo; 03-29-2003 at 04:19 PM.
    If you ever need a hug, just ask.

  5. #5
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    BTW to convert millseconds to seconds just divide by 100.
    You mean by a thousand don't you? And to go from seconds to milliseconds you multiply by a thousand.

    ~ Paul

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by Codeplug
    Lowercase "sleep()" is POSIX and standard C (C99) and is in <unistd.h>. It's not in the Microsoft C-lib however.
    It ain't listed in my copy of C99 Me's a thinking you're wrong on that one.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  7. #7
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    You're right!!
    I was referencing this table and I must have looked at the wrong row.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [pthread] cancellable sleep in win32?
    By cyberfish in forum C++ Programming
    Replies: 2
    Last Post: 08-11-2007, 02:30 AM
  2. Sleep works with just one thread, but not 2
    By finkus in forum C++ Programming
    Replies: 5
    Last Post: 12-01-2005, 09:17 PM
  3. Problem with Sleep() #$@^#$%^
    By intruder in forum C++ Programming
    Replies: 8
    Last Post: 10-11-2004, 06:46 AM
  4. why do we require sleep?
    By jinx in forum A Brief History of Cprogramming.com
    Replies: 43
    Last Post: 07-14-2004, 08:21 AM
  5. Sleep is overrated...
    By Polymorphic OOP in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 01-24-2003, 12:40 PM