![](/img/trans.png)
[英]Tesseract "estimating resolution as 304" line prints word by word + takes >1 second to print. Why and how to supress?
[英]How to print a word every second?
如何在使用fopen("filename.txt","r")
的情况下每秒打印一次单词?
我搜索较早,发现使用了unistd.h
头文件,但是在我的Turbo C ++中不存在这样的头文件。
如果您的编译器支持C ++ 11,则std::thread::sleep_for
是最佳的跨平台解决方案:
#include <chrono>
#include <thread>
std::this_thread::sleep_for(std::chrono::seconds(1));
// or
using namespace std::chrono_literals;
std::this_thread::sleep_for(1s);
如果您被迫使用不支持C ++的编译器,则必须使用特定于平台的功能:
sleep
是POSIX.1-2001的一部分,因此它应在任何兼容的操作系统上运行,包括UNIX,Linux和Mac OS X:
#include <unistd.h>
sleep(1);
Sleep
是WinAPI的一部分:
#include <windows.h>
Sleep(1000); // Note capital "S" and that you specify time in milliseconds
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.