[prev] [index] [next]

C execution: Startup

All C programs must have a main() function.

Executing a C program causes main() to be invoked

  • with command-line arguments (via argc, argv)
  • with stdin, stdout, stderr already open for use
Program execution stops when the main() function returns.
  • return value 0 (EXIT_SUCCESS) indicates "successful completion"
  • return value 1 (EXIT_FAILURE) indicates "problems in execution"
(In fact, any non-zero value indicates execution errors; can use different values for different errors; check return status via $? in Unix shell)