There are no notfications.

main function

The main function is the first function called when a program starts. The return value of main is the termination status that the host environment receives from the program upon exiting. 0 signifies success and a nonzero value signifies failure. Returning from main is equivalent to calling the exit function declared in the stdlib.h header.

Function signatures

The main function has two possible function signatures:

int main(void)
{
}

And another with two parameters:

int main(int argc, char **argv)
{
}

The two parameters can be given any names as long as their types are correct. char **argv is commonly written as char *argv[] for stylistic reasons.

Parameters

As no function has been called before main, the host environment provides the arguments to the function, typically from a command-line or a script. The arguments passed to the program (and subsequently main) upon execution are turned into an array of strings. The first element of the array should always be the name of the program itself. Arrays passed to functions decay into pointers, which is why argv is of the type pointer to a pointer to char.

argc
argument count
The number of arguments passed to the function. Guaranteed to be nonnegative.
argv
argument vector
An array containing the arguments pass to the function. Guaranteed to contain at least one value with the name of the program.

Outputting arguments

The argument array can be outputted just like any other string array passed to a function:

#include <stdio.h> // "puts".

int main(int argc, char **argv)
{
	for (int i = 0; i < argc; ++i)
	{
		puts(*(argv + i)); // Pointer syntax.
		puts(argv[i]); // Array syntax.
	}

	return 0;
}