>what's a more efficient way to pause the program until keypress?
The best portable way is:
Code:
#include <ios>
#include <iostream>
#include <limits>
using namespace std;
int main()
{
//...
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cin.get();
}
The call to ignore will clean up any extraneous characters from the stream so that get actually causes a blocking read. If your stream usage is well thought out then this shouldn't be a problem though.
If you want to terminate the program at any key press rather than just at Enter, you get into the realm of implementation dependent solutions. In that case, the question becomes "How can I read a key press without waiting for Enter?".