c++ Sleep function header file

Sleep header file: #include <Windows.h>

#include <iostream>
#include <Windows.h>
	
int main(void) {
    
    

	while(1) {
    
    
		std::cout << "休眠两秒!" << std::endl;
		Sleep(2000);	//休眠2秒
	}
	
	system("pause");
	return 0;
}

. . . . . . . . . . . . . . . . . . . .
This is written in VC++ and the system is Windows.
And pay attention to the uppercase S, and the compiled source file should not be written as .c, but written as .cpp. For example:
wrong writing:
insert image description here
correct writing:
insert image description here
this is the wrong suffix of the source file, resulting in an error prompt:
insert image description here
this is a lowercase s, resulting in an error prompt:
insert image description here
. . . . . . . . . . . . . . . . . . .
In addition, when writing in the Linux system, lowercase s is required, and the header file must be replaced. As for what to replace, it depends on the situation. For example: sleep(2), means sleep for two seconds. At this time, the unit of the parameter is seconds! ! !
In the Windows system, the unit of the parameter is milliseconds! ! ! . For example: Sleep(2000), means sleep for two seconds.

Guess you like

Origin blog.csdn.net/weixin_46060711/article/details/124522185