need help on exercise in C++ book

Started by
4 comments, last by Qw3r7yU10p! 19 years, 6 months ago
I just bought Beginning C++ Game programming by michael dawson and im on the exercise "lost fortune". I wrote the code and it runs fine,but after it asks for my last name and i press enter it just exits. Why does it exit? please help.
Advertisement
Well, why don't you post your code and we'll see if we can help you. Please use the "source" and "/source" tags (in square brackets) to make it tidy.

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
It probably exits because the application finishes running. If you want to see the final output, you should run it in a console window, or add some code that will delay application exit.
Quick fix to run it and not have to change any code.

1) Click START->Run
2) Type cmd and hit enter
3) now go to the directory you have your compiled applicaion in and run it from there, that way it won't exit.


You can also do it in code using system("pause") or a getch or whatever :) That way you won't have to drop to a DOS box.
This is cross-posted.

The code posted there has a little cin.ignore trick at the end that *should* pause the program as far as I can tell... :/
Hit Ctrl-F5 instead of just F5 to run the app.

This topic is closed to new replies.

Advertisement