Help! I just started learning C++ today, but I am having trouble... When I use the sample code that is in the tutorial... Whenever the code finishes what it is doing the program immediately shuts off before I can even read output and stuff... Is there some setting in windows I need to set so it stops doing this? :o
If u r using windows, put this at the end of your code and make sure u add #include <stdlib.h> to the top of ur code
if u r in linux, i have no clue cause i don't have linux. i don't think that it will work under linux.
If you are in Microsoft Visual C++, simply hit "execute" (!) instead of "go".
Whatever system you use you can do something like this at the very end of your project:
///blah blah blah
cout << "enter any key to exit" << endl;
cin >> dummy;
When u do ur version though, u also have to hit enter after u input the char. So, it really wouldn't be press any key to exit.
you could use getche() as well, or anything that will force the system to wait for input before closing and then ignores the input, for that matter. This technique will work irrespective of operating system or compiler and does not require knowledge of assembly or underlying API (if applicable).
Wow thanks for the help everyone!