Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
3364 connectés 

 


 Mot :   Pseudo :  
 
 Page :   1  2
Page Suivante
Auteur Sujet :

Racine carrée en C++

n°917117
Joel F
Real men use unique_ptr
Posté le 07-12-2004 à 15:31:48  profilanswer
 

Reprise du message précédent :
int main(int,char**) est une prototype de main valide en C++ :o

mood
Publicité
Posté le 07-12-2004 à 15:31:48  profilanswer
 

n°917120
Joel F
Real men use unique_ptr
Posté le 07-12-2004 à 15:32:55  profilanswer
 

gilou a écrit :

Déja, vu qu'il utilise pas les arguments de la ligne de commande, un "int main( )" s'impose.
A+,


 
 :non: en C++ le prottype de main est OBLIGATOIREMENT
int main(int argc, const char** argv)
 
si tu ne veut pas les utiliser, aliase les noms des arguments
 
int main(int,const char**)

n°917151
gilou
Modérateur
Modosaurus Rex
Posté le 07-12-2004 à 16:01:33  profilanswer
 

Joel F a écrit :

:non: en C++ le prottype de main est OBLIGATOIREMENT
int main(int argc, const char** argv)

 
si tu ne veut pas les utiliser, aliase les noms des arguments
 
int main(int,const char**)

Je te conseille de relire The C++ Programming Language de Bjarne Stroustrup, page 46 par exemple, pour t'instruire.
 
Et aussi ceci...

Citation :

The only function in C++ which should not have a function prototype is main. This is because it is illegal for another function to call main within a C++ program.

(de http://www.ul.ie/~flanagan/ee6721/basiccpp.html )
A+,


---------------
There's more than what can be linked! --  Le capitaine qui ne veut pas obéir à la carte finira par obéir aux récifs. -- Il ne faut plus dire Sarkozy, mais Sarkozon -- (╯°□°)╯︵ ┻━┻
n°917154
Lam's
Profil: bas.
Posté le 07-12-2004 à 16:02:27  profilanswer
 

Joel F a écrit :

:non: en C++ le prottype de main est OBLIGATOIREMENT
int main(int argc, const char** argv)


 
 :lol:  
 
Nan, le standard dis juste que main doit forcéement retourner un int, et qu'un compilo doit forcément accepter
"int main(int, const char **);" et "int main();"
 
Après, tu peux avoir un compilo qui autorise des trucs plus folkloriques, comme les variables d'environnement en 3ème paramètre, la valeur de sizeof('a') en 4ème paramètre, etc.
 

n°917160
gilou
Modérateur
Modosaurus Rex
Posté le 07-12-2004 à 16:10:01  profilanswer
 

Citation :

[ http://home.att.net/~jackklein/ctips01.html ]
ANSI/ISO/IEC 9899:1990 International Standard For C
The function called at program startup is named main. The implementation declares no prototype for this function. It can be defined 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[ ]) { /* ... */ }  
The newly ratified update to the C standard in 1999 will make this even clearer, perhaps because of all the clueless who could not understand that only the two formats above, both of which define main to return an int, are valid.  
The draft of the new standard expands on the two definitions above by modifying the wording "It can be defined" to "It shall be defined with a return type of int".
 
ANSI/ISO/IEC 14882:1998 International Standard For C++
An implementation shall not predefine the main function. This function shall not be overloaded. It shall have a return type of type int but otherwise its type is implementation defined. All implementations shall allow both of the following definitions of main:  
The two definitions which follow are identical to those in the C standard


(au detail pres qu'on ecrira int main() et non int main(void) en C++)
A+,


Message édité par gilou le 07-12-2004 à 16:10:45

---------------
There's more than what can be linked! --  Le capitaine qui ne veut pas obéir à la carte finira par obéir aux récifs. -- Il ne faut plus dire Sarkozy, mais Sarkozon -- (╯°□°)╯︵ ┻━┻
n°917175
Joel F
Real men use unique_ptr
Posté le 07-12-2004 à 16:16:29  profilanswer
 

TO SELF : [:dawa] regarder dans le bon bouqin pr la prochaine fois

n°917213
gilou
Modérateur
Modosaurus Rex
Posté le 07-12-2004 à 16:44:37  profilanswer
 

Noter qu'en cherchant des pages illustratives, je suis tombé sur celle là http://homepages.ius.edu/JDRUIN/ht [...] ucture.htm qui utilise void main()... :whistle:  
A+,


---------------
There's more than what can be linked! --  Le capitaine qui ne veut pas obéir à la carte finira par obéir aux récifs. -- Il ne faut plus dire Sarkozy, mais Sarkozon -- (╯°□°)╯︵ ┻━┻
n°917220
Infosactua​lite
Macintosh vs. Windows
Posté le 07-12-2004 à 16:53:32  profilanswer
 

Oula c'est quoi cette querelle d'informaticien ?En tous cas c'est la première fois que j'ai le droit a un QUOTED ! :D
 
Merci a toos!

n°917271
Joel F
Real men use unique_ptr
Posté le 07-12-2004 à 18:03:06  profilanswer
 

gilou a écrit :

Noter qu'en cherchant des pages illustratives, je suis tombé sur celle là http://homepages.ius.edu/JDRUIN/ht [...] ucture.htm qui utilise void main()... :whistle:  
A+,


 
c'est moche :o

mood
Publicité
Posté le   profilanswer
 

 Page :   1  2
Page Suivante

Aller à :
Ajouter une réponse
 

Sujets relatifs
Peut on créer un dossier racine pour faire un site offline ?pourquoi la racine fait jamais comme les autres ? [TreeView] [resolu ]
Config IIS : Erreur 405 sur le POST à la racine d'un rep.[HTACCESS] Simuler la racine du site a partir d'un sous-rep. ??
créarion d'un répertoire & sauvegarde de fichier à la racineEasy PHP : comment devier la racine...
Simplification racine carre?[Easyphp/Apache] Comment modifier le répertoire de la racine
[HTML/CSS] URL racine[servlet/jsp] récuérer le chemin réel de la racine d'une web-app
Plus de sujets relatifs à : Racine carrée en C++


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)