Herrje.
int main() benötigt keinen Rückgabewert.
int main() benötigt keinen Rückgabewert.
Falsch, der Rückgabewert gibt den Exit-Code der Anwendung an.Quote:
und ich hoffe das hat noch ekienr geschrieben aber am Ende deines Hauptprogrammes fehlt der Retrunwert in diesem Fall wäre es 0 da das Programm zuende wäre.
doch, laut Standard schon.Quote:
Herrje.
int main() benötigt keinen Rückgabewert.
void main ist illegal!Quote:
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;8) or in some other implementation-defined manner.
If they are declared, the parameters to the main function shall obey the following
constraints:
— The value of argc shall be nonnegative.
— argv[argc] shall be a null pointer.
— If the value of argc is greater than zero, the array members argv[0] through
argv[argc-1] inclusive shall contain pointers to strings, which are given
implementation-defined values by the host environment prior to program startup. The
intent is to supply to the program information determined prior to program startup
from elsewhere in the hosted environment. If the host environment is not capable of
supplying strings with letters in both uppercase and lowercase, the implementation
shall ensure that the strings are received in lowercase.
— If the value of argc is greater than zero, the string pointed to by argv[0]
represents the program name; argv[0][0] shall be the null character if the
program name is not available from the host environment. If the value of argc is
greater than one, the strings pointed to by argv[1] through argv[argc-1]
represent the program parameters.
— The parameters argc and argv and the strings pointed to by the argv array shall
be modifiable by the program, and retain their last-stored values between program
startup and program termination.
Quote:
Originally Posted by http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdfA return statement in main has the effect of leaving the main function (destroying any objects with automatic storage
duration) and calling std::exit with the return value as the argument. If control reaches the end of main without
encountering a return statement, the effect is that of executing return 0;