Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

void main or int?

Name: Anonymous 2008-04-03 11:50

hey /prog/,
why would you use int main() instead of void main()?

Name: Anonymous 2008-04-03 12:08

``The function called at program startup is named main. The implementation declares no prototype for this function. It shall be defined with a return type of int and with no parameters:
    int main(void) { /* ... */ }
or with two parameters (referred to here as argc and argv, though any names may be used, as they are local to the function in which they are declared):
    int main(int argc, char *argv[]) { /* ... */ }
or equivalent;9) or in some other implementation-defined manner.

9) Thus, int can be replaced by a typedef name defined as int, or the type of argv can be written as char ** argv, and so on.''

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List