return
statementmain
declaration, the void
corresponds to a special type meaning 'nothing'return
statement#include <stdio.h>
void main() {
printf("Welcome !");
return;
}
Nb. A return
always exit a program (i.e. don't execute instructions after the statement).
3. To improve the program, this one can return the 'status' of the execution: 0=SUCCESS, 1=ERROR
int main() {
...
return 0;
}
Nb. Now the program don't return nothing (void
) but a status that is here an int
. As a complement, the stdlib.h
library define two contant EXIT_SUCCESS and EXIT_FAILURE than can replace 0/1.
#include <stdlib.h>
int main() {
...
return EXIT_SUCCESS;
}