Chances are you're not doing anything wrong.
Add the following line to the end of your program:
Put it just before the final closing brace in int main()
You'll then see your window stay open and it'll say "Press any key to continue..." instead of just exiting.
To get around this problem without that extra code, just open up Command Prompt, navigate to the directory that contains your exe, and run it from there. The window won't close after you run the program.