main() function in C -
i've been learning c programming in self-taught fashion weeks, , there questions have concerning main()
function.
all functions must declared in function prototype, , later on, in defintion. why don't have declare
main()
function in prototype first?why have use
int main()
instead ofvoid main()
?what return 0 in
main()
function? happen if wrote program endingmain()
functionreturn 1;
, example?
- you need either definition or prototype in order call function,
main
must never called other function, must not declared. - because c standard says so. operating systems pass return value calling program (usually shell). compilers accept
void main
, non-standard extension (it means "always return 0 os"). - by convention, non-zero return value signals error occurred. shell scripts , other programs can use find out if program terminated successfully.
Comments
Post a Comment