well, there's a kinda semi-standard way of getting around what you want... you can't really close the input stream, but you can use your own input stream and cut it off, and AFAIK, the only way to time something and accept input at the same time is system-dependant (like others have said)
Code:
#include <iostream> //for I/O
#include <ctime> //for standard time functions
void timeAndSpin(const int seconds); //a timer with a spinner
int main()
{
char*line=new char[20]; //to hold the input
std::istream*input=&std::cin; //assign the standard input to your
//stream
std::cout<<"Enter your name: "; //ask for input
input->get(line,20,'\n'); //get it with your stream
std::cout<<"You Entered: "<<line<<std::endl; //confirmation
input=0; //"close" your stream
delete[]line; //free up the memory
timeAndSpin(5); //run the timing function
return 0;
}
void timeAndSpin(const int seconds)
{
char*spinner="|/-\\"; //use a spinner to time
int i=0; //for the position in the spinner
int time=seconds*CLOCKS_PER_SEC; //use a standard constant
int start=clock(); //start the timer
int end; //save memory for the end of the timer
//here we create an interval - how often the spinner moves. I set it
//to every 10th of a second
const int INTERVAL=static_cast<int>(CLOCKS_PER_SEC*0.1f);
//start the spinner
std::cout<<'|';
do
{
//set 'end' variable to now
end=clock();
//if it's time to update the spinner
if(end%INTERVAL==0)
{
//update the 'i' variable
i=(i<4?++i:0);
//output some backspaces, the spinner, and the time
//NOTE: I/O functions take ALOT of time and processing
//power - try not to keep this in a tight loop
std::cout<<"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
<<spinner[i]<<' '<<end<<std::flush;
}
}while(end-start<=time); //keep doing it until time runs out
}
of course putting the timing and input together right is up to you, and that method is pretty processor-intensive (using clock() with a loop)... basically you'll need to find a way to time something and accept input at the same time, and a way to, when you get the input or time runs out, break out of that routine.