Re: iostream vs iostream.h
Quote:
Originally posted by LegendsEnd
Also could someone explain to me what main does? I know that int main is declaring function main to return an integer but...what does that mean/do? I think return 0 just ends the program but is there a way to just leave the screen? I always have to add in an extra cin line so I can see if the last line of code actually worked
A C++ program is made up of functions. The first function that is called when you start your program is main. That's just the way it is. All functions can return a value to the code that called them if they want. By standard convention, main returns an integer to the code that calls it. You don't see the code that calls it, it is the operating system, but that integer is still returned. Most people return 0 because that generally means success. Technically you can return whatever number you want, but it is generally better to stick to convention unless you have a reason not to. So just always put return 0, or if you want to signal a major error try returning a non-zero number (like 1).
As far as adding a cin so you can see the output, that is also very common. Check the FAQs on this board for more information and other ways to stop your results from disappearing, and for why it is int main and <iostream> and all that other good stuff.