+ 5

What's the difference between void main() and int main()?

1st May 2017, 6:10 PM
Bana Itan
Bana Itan - avatar
8 ответов
+ 4
anything before main will determine the return value upon sucessful completion of the program. int main will return an integer, void main will not return anything.
2nd May 2017, 12:54 AM
Krishneel Nair
Krishneel Nair - avatar
+ 2
for C: I once heard from someone that int main was the original way of creating a program, but when time advanced, void main came in. don't k ow the specificks and correct me if i'm wrong ;)
1st May 2017, 7:12 PM
Harm Zeinstra
Harm Zeinstra - avatar
+ 1
void main() function is not expected to return any value, while int main() is to return an integer value.
1st May 2017, 6:54 PM
Malak Samir
Malak Samir - avatar
+ 1
return data type, get the basics again . we usually use void as it accepts all return data type but int for integer return type . eg: int main() { return 1; }
1st May 2017, 7:50 PM
Ujjwal Anand
Ujjwal Anand - avatar
+ 1
I think that void main is non-standard. Basically, main should return 0 if the program finished all work correctly and some other number (called error code) if it failed.
2nd May 2017, 11:52 AM
Valdemar
Valdemar - avatar
0
void mean function main will not return any value after execution . but in int main return any int value compulsory otherwise error raise . void main () { printf("hello"); } __________________________________ int main() { return 0; }
6th Jun 2017, 12:43 PM
Hariom Sharma
Hariom Sharma - avatar
0
void main return null value whereas int main return integer value
6th Jun 2017, 3:35 PM
Gowri manohari.k
0
C++ program can't return void value from 'main', can it? 'void main' was in old C lang, afaik
6th Jun 2017, 7:37 PM
Игорь Копылов
Игорь Копылов - avatar