![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: int, programming |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |
| ||||
| Int means integer, main(), is returning an Integer, hence the int. When It says return, that means that when you say "return 0" in your code. So basically, until it gets to the return statement, it knows that it's job isnt done yet, when it sees that, the "return 0" it knows it has finished. hope that helps |
| ||||
| I think void main() is out of date. Much of programmers suggest that using int main() instead of void main(). Honestly, I don't know why too. Anyway, you don't need to return any value in main() function. It is exceptional. However, it is recommented to return value. From siLenTz Just Sharing my Idea... |
| |||
| The C++ language definition requires that main return an int. To do otherwise is incorrect C++, but many compilers allow it for various reasons, such as tradition, backwards-compatibility and because allowing it extends the language in a way that doesn't affect any other part of it. It is customary for the return value to indicate success, usually by returning zero, or to give an error code that can be used to debug. |
| The Following 2 Users Say Thank You to Konr For This Useful Post: | ||
HelloWorld (07-07-2007), TeraTask (07-07-2007) | ||
| |||
| Quote:
As somebody already mentioned, returning an integer rather than nothing at all is better because then you can determine whether the program exited due to errors. In fact, on many Linux machines, you can print out a special variable to determine the exit success: g++ -std=c++98 -o myprog myprog.cpp && myprog # the program output is here echo $? # if $? shows 0, then myprog exited fine (it exited with 0 errors) As a side note, this is contrary to many other programming implementations, such as the Windows API, where if you return 0 from a function, that means that the function did not exit successfully (did you exit successfully? 0/FALSE). |
| The Following User Says Thank You to rpgfan3233 For This Useful Post: | ||
HelloWorld (07-08-2007) | ||
| ||||
| Quote:
![]() Cuz I've also been wondering with this a while back ago to what language do you use to create a linux application..? Because as you see, windows is really popular because many developers are program their application using C++ or whatever else, while I don't see any specific language that's dedicated to create a linux application. That's one part that my friend and me researching about for his graduate studies ![]() |
| |||
| Quote:
An 'exception' occurs during run-time. Your compiler will give you errors or warnings. |
| The Following User Says Thank You to Konr For This Useful Post: | ||
HelloWorld (07-08-2007) | ||
![]() |
| Thread Tools | |
| Display Modes | |
| |