First of all, change your main() line to be int main()
The problem that you are having is that the program opens, does what it's supposed to do, and then closes. At the end of the program, right above the return 0 line, try entering:
char x;
cin >> x;
What that will do is prompt for a character to be input right before the program closes. Therefore, the program won't automatically close until it gets user input.
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 163
The Queen of DaniWeb
Offline 13,646 posts
since Feb 2002