求助!c++中的等待一秒是什么?
求助!c++中的等待一秒语句是什么?如果是sleep,那么该如何使用?需不需要加头文件?(配置:Windows)
#include <iostream> #include <chrono> #include <thread> int main() { using namespace std::chrono_literals; std::cout << "Hello waiter\n" << std::flush; auto start = std::chrono::high_resolution_clock::now(); std::this_thread::sleep_for(1s); auto end = std::chrono::high_resolution_clock::now(); std::chrono::duration<double, std::milli> elapsed = end-start; std::cout << "Waited " << elapsed.count() << " ms\n"; }