Why int main




















BBetances BBetances 1 1 gold badge 14 14 silver badges 23 23 bronze badges. As in C, because the process will give the OS an exit code. Keltia Keltia Because int is the returncode a program can return to the OS. You can query this value to check if operation has been succesfull.

This was extremely helpfull when using commandline scripts. Toon Krijthe Toon Krijthe And it still is helpful. Commandline scripts are not dead, you know?

Robert 5, 43 43 gold badges 60 60 silver badges bronze badges. Rahul Rahul The Overflow Blog. Does ES6 make JavaScript frameworks obsolete?

Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. Now live: A fully responsive profile. Linked Related When our program is simple, and it is not going to terminate before reaching the last line of the code, or the code is error free, then we can use the void main.

But if we want to terminate the program using exit method, then we have to return some integer values zero or non-zero. In that situation, the void main will not work. So it is good practice to use int main over the void main. Nishtha Thakur.

Article Contributed By :. Easy Normal Medium Hard Expert. Writing code in comment? Please use ide. Load Comments. What's New. Most popular in C Language. We use cookies to ensure you have the best browsing experience on our website.



0コメント

  • 1000 / 1000