Ok, i really do want to wait for a keypress. But the difference is that I want it to time out after a predetermined amount of time.
The only way I could imagine doing this (without using 2 programs and pipes) is by using a loop. Howeve, putting cin.anything() will wait for input which is not exactly what I want.
Here, let me just show you some code. It will explain it a lot better than I can.
(this code is for illustration only. my question is not a concern with THIS code)
any ideas?Code:#include <iostream> #include <ctime> using namespace std; int main(int argc, char *argv[]) { time_t start, end; start = time(0); while( !cin.get() && (difftime(end, start) <= 100) ) end = time(0); if( difftime(end, start) <= 100 ) userAbsent_proceedWithVeryLongProcess() return 0; }



LinkBack URL
About LinkBacks


