windows 未解析的外部符号 _sleep 使用 sleep()?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5574490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:34:40  来源:igfitidea点击:

Unresolved external symbol _sleep Using sleep()?

cwindows

提问by cellpho

I am trying to use the sleep() command. I am using C on windows (visual studio compiler). The command is simply sleep(5);I have windows.h included, time.h, stdio.h. What more do I need?

我正在尝试使用 sleep() 命令。我在 Windows(visual studio 编译器)上使用 C。命令只是sleep(5);我包含 windows.h、time.h、stdio.h。我还需要什么?

回答by Chris Schmich

You want Sleep(note the casing) as defined in the Windows API. It's accessible through Windows.h.

您想要Sleep(注意大小写)在 Windows API 中定义。可以通过Windows.h.

回答by Azeemali Hashmani

The proper syntax to use sleep in Visual Studio compiler is given in windows library

在 Windows 库中给出了在 Visual Studio 编译器中使用 sleep 的正确语法

https://msdn.microsoft.com/en-us/library/windows/desktop/ms686298(v=vs.85).aspx

https://msdn.microsoft.com/en-us/library/windows/desktop/ms686298(v=vs.85).aspx

So for 5 seconds of sleep use

所以对于 5 秒的睡眠使用

Sleep(5000);

You will also have to add the header file

您还必须添加头文件

Windows.h