Alright, I do not believe there is any easy way to do this, but threads are easy, right?
Here is the code that does what you want, I will be back later to explain it if necessary(have to go get my daughter dinner):
Code:
#include <windows.h>
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
void getInput(LPVOID param);
int main() {
DWORD myThreadID;
HANDLE myThread;
int userInput = 0;
cout << "We will start our thread and then sleep for 5 seconds (user timeout)" << endl;
myThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)getInput, &userInput ,0, &myThreadID);
WaitForMultipleObjects(1, &myThread, TRUE, 5000);
CloseHandle(myThread);
if(userInput != 0){
cout << "User entered " << userInput << endl;
}else
cout << endl << "Timeout occured" << endl;
return 0;
}
void getInput(LPVOID param){
cout << "Enter a number: ";
cin >> *((int*)param);
}