![](/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.