|
You last visited: Today at 06:54
Advertisement
c++ anfänger braucht hilfe :S
Discussion on c++ anfänger braucht hilfe :S within the C/C++ forum part of the Coders Den category.
04/22/2013, 16:30
|
#16
|
elite*gold: 724
Join Date: Mar 2011
Posts: 10,480
Received Thanks: 3,319
|
Herrje.
int main() benötigt keinen Rückgabewert.
|
|
|
04/22/2013, 18:36
|
#17
|
elite*gold: 0
Join Date: Dec 2012
Posts: 255
Received Thanks: 110
|
Quote:
Originally Posted by theo1990
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.
|
Falsch, der Rückgabewert gibt den Exit-Code der Anwendung an.
Quote:
Originally Posted by snow911
Herrje.
int main() benötigt keinen Rückgabewert.
|
doch, laut Standard schon.
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.
|
void main ist illegal!
|
|
|
04/22/2013, 20:58
|
#18
|
elite*gold: 724
Join Date: Mar 2011
Posts: 10,480
Received Thanks: 3,319
|
Ja, dass void main() illegal ist, stimmt, aber das meinte ich nicht. Ging nur darum, dass das return nicht explizit angegeben werden muss, aber ich sehe gerade, dass das wohl nur für C99 gilt, unter C++ muss da tatsächlich ein return hin. Tut mir leid.
|
|
|
04/22/2013, 21:27
|
#19
|
elite*gold: 0
Join Date: Feb 2013
Posts: 1,137
Received Thanks: 869
|
Nein, unter C++ muss _kein_ return hin.
Hier nochmal für alle:
Quote:
Originally Posted by http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf
A 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;
|
|
|
|
|
|
Similar Threads
|
Anfänger braucht HILFE.
11/13/2012 - Lord of the Rings Online - 2 Replies
Ich fange mit HDRO an, deshalb wollt ich euch fragen was ich mir für einen Char machen soll: Schurken oder Waffenmeister. Was sind die vor- und Nachteile dieser Klassen?
Machen die Klassen gut DMG?
|
[CS:S] Anfänger braucht Hilfe :>
06/26/2012 - Counter-Strike - 5 Replies
Hallo e*pvp :),
ich habe mir heute css zugelegt und bin somit ein totaler Neuling. Ich habe davor schon CoD4 ESL gespielt, mich als kompletter Ego Shooter Anfänger zu bezeichnen wäre Schwachsinn, aber es war in CoD4 üblich, sein Spiel seinen Bedürfnissen nach anzupassen. Damit meine Ich:
eigene Config
Tastenbinds
verändern des Scoreboards
Befehle auf Tasten legen (Fast Reload, FPS Switch etc.)
|
anfänger braucht hilfe xD
01/19/2012 - Metin2 Private Server - 2 Replies
hey mir ist lw und ich will meine zeit vertreiben wollte mir einen pserver machen den ich auch on bekomm habe nur ich habe kp wie ich ein reboot mache xD habe es einfach nach dem vid. gemacht und bin in mom online (ingame) dann wollte ich mir gm rechte machen, habe es schon mit navicat gemacht nur jetzt muss ich iwie rebooten nur ich weis nicht wie xD
also ich will wissen wie man rebootet und wieder startet pls kommt jetzt nicht mit 1000 links+ und ich weis das es schon 1000+themen gibt...
|
[Anfänger braucht hilfe]
04/26/2011 - CrossFire - 27 Replies
Hi,
seit mir bitte nicht bösse wen ich hir falsch bin...
Allso, ich wollt heute mit Crossfire anfangen...
1. Frage
Was für eine Namen soll ich nehmen darf ich auch groß Bustaben nehmen(?)
darf ich sonderzeichen wie z.B. ()-,+ usw. nehmen?
2.Frage
|
[Anfänger braucht hilfe]
04/25/2011 - Combat Arms - 11 Replies
Allso, ich wollt heute mit Compat Arms anfangen...
1. Frage
Was für eine Namen soll ich nehmen darf ich auch groß Bustaben nehmen(?)
darf ich sonderzeichen wie z.B. ()-,+ usw. nehmen?
2.Frage
Hab ich am Anfang irgentwie Geld? Um im item shop waffen zu kaufen?
3.Frage
|
All times are GMT +2. The time now is 06:54.
|
|