Input with a timeout in C++
问题 I want to have a program where the user have 10 seconds to enter the password. If the timer goes over 10 seconds, the program displays a message. My current code is this: #include <iostream> #include <ctime> #include <string> int main(){ std::string password; int start_s=clock(); int stop_s=clock(); if(stop_s-start_s <= 0){ std::cout << "TIME RAN OUT!"; } std::cout << "Enter your password! \n"; std::cout << "Password: "; std::cin >> password; std::cout << "\n \n"; if (password == "password123