IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C Discussion :

La fonction Main()


Sujet :

C

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Invité
    Invité(e)
    Par défaut La fonction Main()
    Bonjours, à tous,

    Je vais commencer cette après-midi le language C et je bloque dès le départ sur la fonction Main.

    J'ai la norme ISO/IEC 9899꞉1999 n1256 et ISO IEC 9899꞉201x n1570 sous les yeux qui sont toutes les 2 les tous derniers brouillons des normes définitives du C99 et C11 et elles indiquent ceci:

    5.1.2.2.1 Program startup
    1 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.
    2 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.
    Or je vois un peu partout y compris dans mon livre intitulé
    Le livre du C : Premier langage (Claude Delannoy) mais aussi ici Le C en 20 heures des fonctions Main qui semble ne pas respecter les normes C99/C11.
    Quelques exemples (raccourci):
    int main() {/*...*/} http://c.developpez.com/tutoriels/20...s/?page=page_2
    void main() {/*...*/} http://www.exercices-corriges.com/20...l#.U29Ri00U9hF
    int main(void) {/*...*/} (La bonne en principe ?)

    Pourquoi ? Comment faut-il déclarer les fonctions Main ?
    Merci d'avance.
    Dernière modification par Domi2 ; 27/12/2015 à 16h42. Motif: Lien non pérenne

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 21
    Dernier message: 20/06/2006, 16h49
  2. fonction main en C++
    Par steph_nied dans le forum C++
    Réponses: 3
    Dernier message: 26/05/2006, 15h03
  3. arguments dans ma fonction main
    Par salseropom dans le forum C
    Réponses: 10
    Dernier message: 15/03/2006, 23h12
  4. la fonction main
    Par harvouj dans le forum Langage
    Réponses: 1
    Dernier message: 13/02/2006, 01h34

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo