I like to use getline(), since it cleans out the keyboard input buffer, including the '\n' (for the benefit of subsequent >>cin or getline() operations.
Something like:
Code:
#include <iostream>
int main()
{
void wait_for_enter(void);
char name[BUFSIZ];
std::cout << "Let's play a game: " << std::endl << std::endl;
std::cout << "Press \"Enter\" when you are ready: ";
wait_for_enter();
std::cout << std::endl << " OK! Ready to begin" << std::endl;
std::cout << std::endl << " Please enter your name: ";
std::cin.getline(name, sizeof(name));
std::cout << std::endl << " Hi, " << name << std::endl;
// etc.
// etc.
return 0;
}
void wait_for_enter(void)
{
char ch[BUFSIZ];
std::cin.getline(ch, sizeof(ch));
}