+ 1

Why int main and not void main?

Void main just seems a lot easier. Idk. I feel stupid asking this.

5th Dec 2024, 10:40 PM
TheMunchkinSolo
TheMunchkinSolo - avatar
2 Answers
+ 7
Native applications are generally expected to return a value to the operating system. This allows shell scripts to branch based on your application's return code. In windows/MS-DOS you can see that code with: echo %ERRORLEVEL% In Linux or MacOS, you can see the exit code with: echo $? For some applications this might not matter. If you write an app that might be called in a shell script, the exit code can be helpful.
5th Dec 2024, 11:32 PM
Jerry Hobby
Jerry Hobby - avatar
+ 2
Oh ok got it
5th Dec 2024, 11:42 PM
TheMunchkinSolo
TheMunchkinSolo - avatar