RFC: C++ "Hit any key to continue..." solution
So, I've been searching for a cross platform way (works on UNIX and Windows) to implement "Hit any key to continue..." functionality.
Specificaly, a better solution than any that are given here:
http://faq.cprogramming.com/cgi-bin/...&id=1043284385
I have come up with (I think) a cross platform, C++ solution that takes care of a terminal environment that does input line buffering
Code:
#include <iostream>
using namespace std;
int main() {
cout << "\nPress any key to continue..." << endl;
streambuf *pbuf;
pbuf=cin.rdbuf()->setbuf(NULL, 1);
pbuf->sgetc();
return 0;
}
What do people think of that? Will it work on windows?