The main() function

Every C program coded to run in a hosted execution environment contains the definition (not the prototype) of a function called main(), which is the designated start of the program

#include <stdio.h> /* comment */  // i)
int main(void) // ii)
{ // iii)
   printf("Structured Programming in C!\n");  // 
   return 0; // iv)
} // v)
  • i)- tells compiler about standard input and output functions (i.e. printf + others)
  • ii)- the main function
  • iii)- Begin of the main function
  • iv)- Return a flag success value to the operating system
  • v)- End of main function
int main (void) { body}(1)
int main (int argcchar *argv[]) { body}(2) 
int main (int argcchar *argv[] , other_parameters ) { body }(3) /* another implementation-defined signature */



  • argc-Non-negative value representing the number of arguments passed to the program from the environment in which the program is run.
  • argv-Pointer to an array of pointers to null-terminated multi-byte strings that represent the arguments passed to the program from the execution environment (argv[0] through argv[argc-1]). The value of argv[argc] is guaranteed to be ​0​.
  • body-The body of the main function
  • other_parameters-Implementations may allow additional forms of the main function.