I just wanna ask that what is the difference between
void main(void)
and
main()
I just wanna ask that what is the difference between
void main(void)
and
main()
void main (void) is a function prototype
main() is a function call.
Yep... main is just a subrotine like all others... It's prototype is in the language statup code.
you mean that main should be declared as follow
void main()
No, that is not at all what I mean. Declaring main as
is almost never correct. Certainly for the typical user with a full operating system, and the standard C implementation, it is incorrect. main returns an int. See the FAQ (11.12b) for when main might not return int.Code:void main
what i understand from the FAQs is that code must be like this
Code:int main(void) { . . . . . return(0); }
That is one of the correct formats. Void main() is never correct in C.
Aha! that's why my compiler always warn me "main should return a value".
Coming back to me question, what i understand from all this discussion that
main()
means that i am clling the main function that is already declared in start up code.
while in
void main(void)
i am re-declaring main's prototype in wrong way!