Is there any case that allowed you to write the main function only. Ex: main () | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

Is there any case that allowed you to write the main function only. Ex: main ()

7th Jun 2019, 4:37 AM
Ahmed Zakree
Ahmed Zakree - avatar
3 Antworten
+ 6
that was allowed in early version of C and void main();, but now main is only allowed to return an int, that's why only int main(); is allowed now
7th Jun 2019, 5:53 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 19
Ahmed Zakree main() is a function so it is not possible that any compiler will allow you to write a function without a return type. There are few things which you should take note of : 1. The int is the main() function's return type. That means that main() will return an integer. 2. main( ) was tolerated by the C90 compilers but not by C99 compilers which means its not a part of C99 standard anymore, so don't do this. 3. Even void main() is not a standard form ,some compilers allow this, but none of the standards have ever listed it as an option. Therefore, compilers don't have to accept this form, and several don't. Again, stick to the standard form, and you won't run into problems if you move a program from one compiler to another.
7th Jun 2019, 5:57 AM
Night_fury~
Night_fury~ - avatar
+ 4
This is not allowed in current version.
7th Jun 2019, 9:50 AM
Yashvi Shah
Yashvi Shah - avatar