Transfer from https://www.cnblogs.com/yssrf-possible/p/8057382.html
Function name: sleep
Function: Suspend execution for some time
用 法: unsigned sleep(unsigned seconds);
Tape used in VC header files
#include <windows.h>
- In gcc compiler, header files used vary from different version of gcc
linux system need to add header files
#include <unistd.h>
note:
-
In the first VC in Sleep English characters to uppercase "S"
-
In standard C is sleep, do not use the following capital ... capital to illustrate specific what you see what the compiler. Simply put, VC with Sleep, the other always use sleep.
Sleep function of the general form:
Sleep(unisgned long);
Wherein, Sleep () inside the unit, in milliseconds, so if you want the function to stay one second, it should be Sleep (1000);
- Under Linux, sleep in the "s" is not capitalized
- sleep () which is in seconds, rather than milliseconds.
- Under linux, using g ++ compiler, was added unistd.h header file, gcc can not add the plus, because the standard C files in there sleep.
Example:
#include <windows.h>
int main(){
int a;
a=1000;
Sleep(a);/* VC 使用Sleep*/
return 0;
}