main() function in C -


i've been learning c programming in self-taught fashion weeks, , there questions have concerning main() function.

  1. all functions must declared in function prototype, , later on, in defintion. why don't have declare main() function in prototype first?

  2. why have use int main() instead of void main()?

  3. what return 0 in main() function? happen if wrote program ending main() function return 1;, example?

  1. you need either definition or prototype in order call function, main must never called other function, must not declared.
  2. 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").
  3. by convention, non-zero return value signals error occurred. shell scripts , other programs can use find out if program terminated successfully.

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -