add the line system("pause"); before return;
omg, why don't take a hammer and smash the keyboard instead?
Because the first idea would help the OP, while the second would not.
A self-acknowledged newbie just learning the very bare-bone basics would do well to just use system("pause"). Sure, it's not the best solution at all, but it's by far the easiest for a newbie to understand, instead of trying to explain something like, "Just open your command prompt, change your directory, and execute your application!
" (Open my whatnow, change my whajhamjig, and assassinate my job application? Why do people keep throwing random terms at me!), or giving broad sweeping suggestions that aren't really helpful, ("Listen simply: Uninstall your entire IDE, forget everything you ever knew, install -my- favorite IDE, and start from scratch! You have to do this, or you'll forever be doomed!
He'll have plenty
of time to find out why system("pause") is a bad idea, but first he ought to get past page 2 of his programming book. When someone is at that early a stage of learning, you should give the most straightforward and easiest solution, instead of potentially complicating things for them and having them drop programming because it's "too hard" for them.
Seriously... "std::cout << "Please enter your name:" << std::endl;
"? He's on page 2 or 3! Make it as easy as possible, before making it as 'correct' as possible. If you are really afraid of the horrible horrendous dangers
of the vile
system("pause"), then just tell him to use Sleep(3000) or something equally simple, like get(). But before anyone breaks into, "He should structure his programs properly in a loop!
". That's correct... and if we let him actually get to the chapter that teaches him about loops, he'll rapidly learn that knowledge in a week or two.