Program Running Correctly in Compiler, Not As Executable

Strange issue involving Code::Blocks. As most everyone will know, while you are working on a C++ project in CodeBlocks, the compiler automatically creates an executable file for you that corresponds to the C++ source code you are working on, and updates it whenever you build the C++ program. My question is this: can anybody think of a reason why a program would run correctly in Code::Blocks, but would not run correctly as the executable file that Code::Blocks created?

The program in question is quite basic as C++ programs go. It is designed to minimize the redundancy of grading standardized-test scores; it gets the number of students from the user, then uses nested loops in order to get a name and four test scores for each student. These scores are then passed to a function which drops the lowest score and takes the average of the three highest scores. The names and adjusted average scores are then all displayed in list form.

The problem I'm having is that the executable file closes itself out after finishing the user-input stage; after the names and scores are added, the program simply closes rather than displaying the list of names and scores. The program works perfectly when it is compiled and run in CodeBlocks, but it doesn't work as an executable.

Any ideas? The only thing I did with this program that was abnormal in any way was that I used the string.h file to create an array of strings (for the names); but since the compiler didn't object to it, I figured it wouldn't have problems during the translation to machine language.
Code Blocks is a very nice IDE that keeps the console open for you. Naturally once the program execution reached the end of main, the program would close. To make it wait for a bit, see http://cplusplus.com/forum/beginner/1988/
Hi ,
Can he use the sytem("pause");
Thank you, guys. That's really an annoying problem, but it seems quite easily fixed in the end. I found that the

1
2
cin.get();
cin.get(); 


inserted before "return 0" worked quite nicely.
Topic archived. No new replies allowed.