0
如何延遲C++中的輸出?我試圖尋找類似的問題,但我沒有找到任何使用'ctime'庫的解決方案。請幫助。使用'ctime'庫延遲C++的輸出
如何延遲C++中的輸出?我試圖尋找類似的問題,但我沒有找到任何使用'ctime'庫的解決方案。請幫助。使用'ctime'庫延遲C++的輸出
看一看this答案。
你可以使用std::this_thread::sleep_for(std::chrono::milliseconds(x));
例如:
#include <iostream>
#include <chrono>
#include <thread>
int main()
{
int x{3000};
std::cout << "Start waiting\n";
std::this_thread::sleep_for(std::chrono::milliseconds(x));
std::cout << "Done waiting\n";
return 0;
}
問的這種方式,你將不得不在尋找答案 –
一個「延遲」你需要重新詞組你的問題,顯示你已嘗試 – cctan
您可以使用'std :: time()'獲取當前時間,然後使用循環,直到'std :: time()'告訴您已經循環了足夠長的時間? – Galik