You most likely compiled and run it inside an IDE. The console behavior will depend on how you configure the IDE.
To solve this, either:
1.) Open command prompt, "Start->Run", type "cmd", hit Return Key. Then once the command prompt is open, browse through the directory where you compiled the program and type the program name. This will not close the command prompt unless you have something else in your code that will force the console to close.
2.) Tell us what IDE you are using. This way we can tell you how to keep the console open after running the project.
Seconding what vince1027 said. Also, here's what I told the last guy who had this problem:
When you double click on the icon of an exe, it will run, and close as soon as it's finished.
If you use the command line to execute the exe, it will run, and the window will stay open even after the program is done. Then you have all the time you need to read your output.
Never used cmd before? It isn't so hard:
Start -> Run -> enter "cmd", hit enter -> enter the name of your program, hit enter