Why does c allow main() even when it is not int main() or void main()?

前端 未结 3 1952
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-21 19:57

While reading the K&R 2nd edition I noticed that the programs always began with \"main(){\". I had always thought that main() had to have int or void before it. So that

3条回答
  •  借酒劲吻你
    2020-12-21 20:04

    Syntax most of times depends on the compiler. For example, when you use visual c++ you write "void main" but when you use GCC, you should write "int main()" and then return 0 or 1 if the program finished good or bad.

提交回复
热议问题