I want to know how can i read the standard input just for 5 seconds like you just have 5 seconds to write.
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string mystr;
cout << "What's your name? ";
getline (cin, mystr);
cout << "Hello " << mystr << ".\n";
cout << "What is your favorite team? ";
getline (cin, mystr);
cout << "I like " << mystr << " too!\n";
return 0;
}
Like that the user have all the time he want to write. Did getline or read have any option to force the getline to stop after 5sec ?
Thank you