在C++中,您可以使用標準庫中的 <iostream>
和 <chrono>
頭文件實現程序暫停
#include <iostream>
#include <chrono>
#include <thread>
int main() {
std::cout << "程序執行完畢,按任意鍵繼續...\n";
// 等待用戶輸入
std::cin.get();
return 0;
}
在這個示例中,std::cin.get()
會阻塞程序執行,直到用戶按下回車鍵。這樣,程序就會暫停執行,直到用戶繼續操作。