LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   int main() (https://www.linuxquestions.org/questions/programming-9/int-main-13358/)

gurra 02-02-2002 06:08 AM

int main()
 
why use "int main()" when you can use "void main()"?

acid_kewpie 02-02-2002 06:28 AM

it's always good to return an exit code from a program. the value you reply can infer wether the program executed correctly. nearly all programs return exit codes. for example...

[chris@trevor chris]$ ls hello
ls: hello: No such file or directory
[chris@trevor chris]$ echo $?
1
[chris@trevor chris]$ touch hello
[chris@trevor chris]$ ls hello
hello
[chris@trevor chris]$ echo $?
0
[chris@trevor chris]$

so from this we can tell if ls was successful or not.


All times are GMT -5. The time now is 06:34 AM.