Sleep(unsigned int seconds) function


To illustrate the call to functions, the author use the sleep function to wait 2 seconds between successive calls, like the code bellow.

int main (int argc, const char * argv[]) { congratulateStudent("Mark", "Cocoa", 5); sleep(2); congratulateStudent("Bo", "Objective-C", 2); sleep(2); congratulateStudent("Mike", "PHP and PostgreSQL", 5); sleep(2); congratulateStudent("Ted", "iOS", 5); return 0; }

The Xcode IDE show the following warning: “Implicit declaration of function ‘sleep’ is invalid”.

The text that follow inform that the sleep() function is declared in stdlib.h. But, the warning was not cleared. According to the BSD Library Functions Manual, the sleep() function is defined in the unistd.h header file, instead of stdlib.h.


Thanks when I included

the warning disappeared.


For Xcode 5, for help with any function or command do the following:

  1. Select the function or command you need help with.

  2. Then click “Help”, then scroll down to “Quick Help for Selected Item”.

  3. Select OS X Man Pages which will take you to the documentation of the selected item.