Hey there! I'd like to start out by saying that I'm learning C++ out of curiosity and boredom. I'm not taking any formal classes, but I do have a book (which I suspect is outdated) and I'm leaning heavily on this website's tutorial resources.
Most of my questions (for there will probably be many) will deal with why something works, as opposed to just making it work. I figure that if I know the why of something then being able to work out the how on my own will be easier (problem solving ftw).
The book I bought was gotten from a half price bookstore for pennies on the dollar, it's called 'Sam's Teach Yourself C++ in 21 days". The latest publication copyright on the inside is for 2000 and he doesn't mention any operating system later than Windows 2000. (I'm running on XP Pro)
I've completed two lessons in his book and one or two lessons from this site and run into some discrepencies. I'll post my first problem now. (I'm using the free Code Blocks compiler btw)
This is the code supplied in the book. It works, but the only problem is that when executed by double-clicking the exe file the program runs and immediately terminates.
This site's tutorial for the same program advises this code:
The difference is return 0; and cin.get(); When I run this one the program properly waits for me to press enter once running before it completely terminates.
What's the difference between these two lines of syntax? Is 'return 0;' working as it should? So far, I've been using the tutorials in the book (the book supplies a lot more whys and hows than this website) and just substituting 'cin.get();' for 'return 0;' whenever I run across it.
Last night I ran into another problem with this code substitution that doesn't make any sense to me. I was calling functions, but right now I'm at work and don't have my source code. If nobody minds I'll go ahead and post my problem code up tonight or tomorrow.