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 :

valeur de gets


Sujet :

C

  1. #1
    Membre confirmé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 460
    Points
    460
    Par défaut valeur de gets
    Bonjour,

    J'ai un souci avec le premier gets du code. En effet en faisant le choix, le programme zappe le premier gets ! Cependant le premier gets me laisse entrer ma valeur ! Je suppose que gets lit quelque chose et le prend pour valeur mais je ne vois pas où cela se passe !

    Voici le code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    #include<stdio.h>
    #include<stdlib.h>
     
    //-----< ENTETES DE FONCTIONS >-----//
     
    void AFFICHAGE_DE_LA_CMD();
    void MENU();
     
    //----------------------------------//
     
     
     
    //-----< FONCTION PRINCIPALE >-----//
     
    int main (void)
    {
         AFFICHAGE_DE_LA_CMD();
     
         while ( 1 )
               {
                         MENU();
               }
    }
     
    //---------------------------------//
     
     
     
     
     
     
     
    void AFFICHAGE_DE_LA_CMD()
    {
         system("echo off");
         system("title CREATION TACHES PLANIFIEES");
         system("MODE CON lines=40 cols=83");
         system("color 19");
    }
     
     
    void MENU()
    {
     
           int choix=0;
           int validation=0;
           char HM[5];
           char CHEMIN[999];
           char commande_AT[999];
           FILE *taches=fopen("taches.txt","w");
     
           printf(" \n +------------------------------------------------------------------------------+\n");
           printf(" |                                       MENU                                   |\n");
           printf(" +------------------------------------------------------------------------------+\n");
           printf(" |                                                                              |\n");
           printf(" |                              [1] Cr\202er une tache                             |\n"); 
           printf(" |                                                                              |\n");
           printf(" |                             [2] Supprimer les taches                         |\n");
           printf(" |                                                                              |\n");
           printf(" +------------------------------------------------------------------------------+\n\n");
           printf("                             Choix (1/2) : ");
     
           scanf("%d",&choix);
     
           if ( choix==1 )
              {
                         printf("\n +------------------------------------------------------------------------------+\n");
                         printf(" |                        REGLAGE DE L'HEURE D'EXECUTION                        |\n");
                         printf(" +------------------------------------------------------------------------------+\n");
                         printf(" |       Rentrez l'information au format suivant -> heure:min  ex 08:34         |\n");
                         printf(" +------------------------------------------------------------------------------+\n\n");
                         printf("                      valeur : \n\n");
                         gets(HM);
                         printf(" +------------------------------------------------------------------------------+\n");
                         printf(" |                        CHEMIN D'EXECUTION DE LA TACHE                        |\n");
                         printf(" +------------------------------------------------------------------------------+\n");
                         printf(" |                 exemple :   C:\\DOS1\\DOS2\\nom_fichier.***                     |\n");
                         printf(" +------------------------------------------------------------------------------+\n\n");
                         printf("                      valeur : ");
                         gets(CHEMIN);
     
                         sprintf(commande_AT," AT \"%s\" /EVERY:l,ma,me,j,v,s,d \"%s\" ", HM, CHEMIN);
                         fprintf(taches," AT %s /EVERY:l,ma,me,j,v,s,d %s ", HM, CHEMIN );
                         system(commande_AT);
                         fclose(taches);
              }
     
     
           if ( choix==2 )
              {
                         printf("\n +------------------------------------------------------------------------------+\n");
                         printf(" |                        CONFIRMATION DE LA SUPPRESSION                        |\n");
                         printf(" +------------------------------------------------------------------------------+\n\n");
                         printf("                      valeur (1->oui)(2->non): ");
                         scanf("%d",&validation);
     
                                          if ( validation==1 )
                                             {
                                                              system("AT /DELETE /YES");
                                                              printf("\n +------------------------------------------------------------------------------+\n");
                                                              printf(" |                              TACHES SUPPRIMEES                               |\n");
                                                              printf(" +------------------------------------------------------------------------------+\n\n");
                                             }
     
                                        else { system("exit"); }     
              }
     
     
           if ( choix==3 )
              {
                       system("exit");
              }
     
    }
    Merci encore
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  2. #2
    Expert confirmé
    Avatar de Thierry Chappuis
    Homme Profil pro
    Enseignant Chercheur
    Inscrit en
    Mai 2005
    Messages
    3 499
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Suisse

    Informations professionnelles :
    Activité : Enseignant Chercheur
    Secteur : Industrie Pharmaceutique

    Informations forums :
    Inscription : Mai 2005
    Messages : 3 499
    Points : 5 360
    Points
    5 360
    Par défaut
    gets() saisit une chaine à partir du flux d'entrée standard et la place chacun de ses caractères dans un tableau de caractères dont l'adresse est passée en 1er argument. Cette fonction est un bug. Elle est officiellement dépréciée par la norme. Il est donc fortement recommandé de ne pas l'utiliser au profit de fgets() (qui est bien plus sûre).

    Thierry
    "The most important thing in the kitchen is the waste paper basket and it needs to be centrally located.", Donald Knuth
    "If the only tool you have is a hammer, every problem looks like a nail.", probably Abraham Maslow

    FAQ-Python FAQ-C FAQ-C++

    +

  3. #3
    Membre confirmé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 460
    Points
    460
    Par défaut
    Ok merci, je ne connais pas cette fonction. Je suis allé voir votre lien mais je n'ai pas trop compris.
    Qu'est ce que je suis censé mettre comme flux. Quand je mets stdin il me rétorque à l'exécution que la liste est vide.

    Merci d'avence
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  4. #4
    Membre régulier
    Profil pro
    Étudiant
    Inscrit en
    Août 2007
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2007
    Messages : 168
    Points : 82
    Points
    82
    Par défaut
    Citation Envoyé par darkwall_37 Voir le message
    Bonjour,

    J'ai un souci avec le premier gets du code. En effet en faisant le choix, le programme zappe le premier gets ! Cependant le premier gets me laisse entrer ma valeur ! Je suppose que gets lit quelque chose et le prend pour valeur mais je ne vois pas où cela se passe !
    beh je ne suis pas si forte en c mais je vais essayé de t'aider :

    tu as écrit :
    scanf("Md",&choix);
    puis
    gets(hm);

    lors de l'execution de scanf(...) la valeur entrée est le choix MAIS dans le flux il reste le caractère "entrer" que tu as presser .
    lors de l'execution de gets(...) elle prends comme valeur le caractère "entrer" qui a rester dans le flux .
    ALORS la solution est aprés scanf tu met l'instruction "getchar();" puis le programme ne va pas zapper le gets

    bon courage

  5. #5
    Membre confirmé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 460
    Points
    460
    Par défaut
    Merci ! bon de toute façon leur histoire de fgets ça marche pas parce que je ne sais pas m'en servir correctement a priori donc peut importe j'ai collé un fflush(stdin) avant chaque gets et ça marche nikel !

    Merci
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  6. #6
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    Citation Envoyé par darkwall_37 Voir le message
    Merci ! bon de toute façon leur histoire de fgets ça marche pas parce que je ne sais pas m'en servir correctement a priori donc peut importe j'ai collé un fflush(stdin) avant chaque gets et ça marche nikel !

    Merci
    Plutôt que d'écrire de bêtise, instruit toi :
    http://emmanuel-delahaye.developpez....tes.htm#saisie
    "The quieter you become, the more you are able to hear"
    "Plus vous êtes silencieux, plus vous êtes capable d'entendre"

  7. #7
    Membre confirmé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 460
    Points
    460
    Par défaut
    Des bétises certes mais ça marche, je n'arrive pas à mettre en œuvre ton fgets ! et pourtant j'ai essayé !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    #include<stdio.h>
    #include<stdlib.h>
     
    //-----< ENTETES DE FONCTIONS >-----//
     
    void AFFICHAGE_DE_LA_CMD();
    void MENU();
     
    //----------------------------------//
     
     
     
    //-----< FONCTION PRINCIPALE >-----//
     
    int main (void)
    {
         AFFICHAGE_DE_LA_CMD();
     
         while ( 1 )
               {
                         MENU();
               }
     
         system("exit");
    }
     
    //---------------------------------//
     
     
     
     
     
     
     
    void AFFICHAGE_DE_LA_CMD()
    {
         system("@echo off");
         system("title CREATION TACHES PLANIFIEES");
         system("MODE CON lines=15 cols=83");
         system("color 19");
    }
     
     
    void MENU()
    {
     
           int choix=0;
           int validation=0;
           char HM[5];
           char CHEMIN[999];
           char commande_AT[999];
           FILE *taches=fopen("taches.txt","w");
     
           printf(" \n +------------------------------------------------------------------------------+\n");
           printf(" |                                       MENU                                   |\n");
           printf(" +------------------------------------------------------------------------------+\n");
           printf(" |                                                                              |\n");
           printf(" |                            [1] Cr\202er une tache                               |\n"); 
           printf(" |                                                                              |\n");
           printf(" |                     [2] Regler l'heure de reboot du PC                       |\n");
           printf(" |                                                                              |\n");
           printf(" |                           [3] Supprimer les taches                           |\n");
           printf(" |                                                                              |\n");
           printf(" +------------------------------------------------------------------------------+\n\n");
           printf("                                   Choix (1/2) : ");
     
           scanf("%d",&choix);
     
           if ( choix==1 )
              {
     
                         system("@echo off");
                         system("title AJOUT DE TACHES");
                         system("MODE CON lines=8 cols=83");
                         system("color 19");
     
                         fflush(stdin);
                         printf("\n +------------------------------------------------------------------------------+\n");
                         printf(" |                        REGLAGE DE L'HEURE D'EXECUTION                        |\n");
                         printf(" +------------------------------------------------------------------------------+\n");
                         printf(" |       Rentrez l'information au format suivant -> heure:min  ex 08:34         |\n");
                         printf(" +------------------------------------------------------------------------------+\n\n");
                         printf("                      valeur : ");
                         fflush(stdin);
                         gets(HM);
                         printf(" +------------------------------------------------------------------------------+\n");
                         printf(" |                        CHEMIN D'EXECUTION DE LA TACHE                        |\n");
                         printf(" +------------------------------------------------------------------------------+\n");
                         printf(" |                 exemple :   C:\DOS1\DOS2\nom_fichier.***                     |\n");
                         printf(" +------------------------------------------------------------------------------+\n\n");
                         printf("                      valeur : ");
                         fflush(stdin);
                         gets(CHEMIN);
     
                         system("title CREATION TACHES PLANIFIEES");
                         system("MODE CON lines=15 cols=83");
     
                         sprintf(commande_AT," AT %s /EVERY:l,ma,me,j,v,s,d %s ", HM, CHEMIN);
                         fprintf(taches," AT %s /EVERY:l,ma,me,j,v,s,d %s ", HM, CHEMIN );
                         system(commande_AT);
                         fclose(taches);
              }
     
     
           if ( choix==2 )
              {
                         char HR[5];
                         char REBOOT[999];
     
                         system("title HEURE DE REBOOT");
                         system("MODE CON lines=9 cols=83");
     
                         printf("\n +------------------------------------------------------------------------------+\n");
                         printf(" |                          REGLAGE DE L'HEURE DE REBOOT                        |\n");
                         printf(" +------------------------------------------------------------------------------+\n");
                         printf(" |       Rentrez l'information au format suivant -> heure:min  ex 08:34         |\n");
                         printf(" +------------------------------------------------------------------------------+\n\n");
                         printf("                            valeur : ");
                         fflush(stdin);
                         gets(HR);
     
     
                         sprintf(REBOOT," AT %s /INTERACTIVE /EVERY:l,ma,me,j,v,s,d Shutdown -r", HR);
                         fprintf(taches," AT %s /INTERACTIVE /EVERY:l,ma,me,j,v,s,d Shutdown -r ", HR);
                         system(REBOOT);
                         fclose(taches);
     
                         system("title CREATION TACHES PLANIFIEES");
                         system("MODE CON lines=15 cols=83");
     
              }
     
     
           if ( choix==3 )
              {
     
                         system("title SUPPRESSION DE TACHES");
                         system("MODE CON lines=5 cols=83");
     
                         printf("\n +------------------------------------------------------------------------------+\n");
                         printf(" |                        CONFIRMATION DE LA SUPPRESSION                        |\n");
                         printf(" +------------------------------------------------------------------------------+\n\n");
                         printf("                              valeur (1/2): ");
                         scanf("%d",&validation);
     
                                          if ( validation==1 )
                                             {
                                                              system("AT /DELETE /YES");
                                                              printf("\n +------------------------------------------------------------------------------+\n");
                                                              printf(" |                              TACHES SUPPRIMEES                               |\n");
                                                              printf(" +------------------------------------------------------------------------------+\n\n");
                                             }
     
                                        else { system("exit"); }     
     
                         system("title CREATION TACHES PLANIFIEES");
                         system("MODE CON lines=15 cols=83");
              }
     
     
           if ( choix==3 )
              {
                       system("exit");
              }
     
    }
    Comme cela ça marche essayes si tu ne me crois pas !
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  8. #8
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    Reste appuyé sur une touche quelques minutes lors du gets(HM), et tu verras si ça marche toujours....
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  9. #9
    Membre confirmé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 460
    Points
    460
    Par défaut
    lol, faut pas abuser non plus : je cherche pas par tous les moyens à faire planter le programme ! tu n'as qu'a mettre tes fgets et si ça marche je suis preneur sinon j'ai déjà essayé et j'ai pas envie de me reprendre la tête, je m'y repencherais à l'occasion.
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  10. #10
    Expert confirmé
    Avatar de Thierry Chappuis
    Homme Profil pro
    Enseignant Chercheur
    Inscrit en
    Mai 2005
    Messages
    3 499
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Suisse

    Informations professionnelles :
    Activité : Enseignant Chercheur
    Secteur : Industrie Pharmaceutique

    Informations forums :
    Inscription : Mai 2005
    Messages : 3 499
    Points : 5 360
    Points
    5 360
    Par défaut
    Citation Envoyé par darkwall_37 Voir le message
    lol, faut pas abuser non plus : je cherche pas par tous les moyens à faire planter le programme !
    Toi, non! Mais l'utilisateur lambda... parfois (souvent?)!

    Thierry
    "The most important thing in the kitchen is the waste paper basket and it needs to be centrally located.", Donald Knuth
    "If the only tool you have is a hammer, every problem looks like a nail.", probably Abraham Maslow

    FAQ-Python FAQ-C FAQ-C++

    +

  11. #11
    Expert éminent sénior
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 67
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Points : 20 985
    Points
    20 985
    Par défaut
    Citation Envoyé par Thierry Chappuis Voir le message
    Toi, non! Mais l'utilisateur lambda... parfois (souvent?)!
    En tout cas, les 12 ouistitis qui me servent à tester les entrées ça ne va pas arréter.
    Pas de Wi-Fi à la maison : CPL

  12. #12
    Expert éminent sénior
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 67
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Points : 20 985
    Points
    20 985
    Par défaut
    Citation Envoyé par Emmanuel Delahaye Voir le message
    En tout cas, les 12 ouistitis qui me servent à tester les entrées ça ne va pas arréter.
    Pas de Wi-Fi à la maison : CPL

  13. #13
    Expert éminent sénior
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 67
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Points : 20 985
    Points
    20 985
    Par défaut
    Citation Envoyé par darkwall_37 Voir le message
    Des bétises certes mais ça marche, je n'arrive pas à mettre en œuvre ton fgets ! et pourtant j'ai essayé !
    <...>
    Comme cela ça marche essayes si tu ne me crois pas !
    Peut importe que 'ça marche ou pas'...
    • gets() est un bug qui ne doit pas être utilisé.
    • fflush() n'est défini que pour les flux sortants.

    Voici une version plus sûre et plus portable :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
     
    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
     
    static void purge (void)
    {
       int c;
       while ((c = getchar ()) != '\n' && c != EOF)
       {
       }
    }
     
    static void clean (char *s)
    {
       char *p = strchr (s, '\n');
       if (p != NULL)
       {
          *p = 0;
       }
       else
       {
          purge ();
       }
    }
     
    //---------------------------------//
     
    void AFFICHAGE_DE_LA_CMD (void)
    {
       system ("@title CREATION TACHES PLANIFIEES");
       system ("@MODE CON lines=15 cols=83");
       system ("@color 19");
    }
     
    void MENU (void)
    {
     
       int choix = 0;
       int validation = 0;
       char HM[5];
       char CHEMIN[999];
       char commande_AT[999];
       FILE *taches = fopen ("taches.txt", "w");
     
       printf
          (" \n +------------------------------------------------------------------------------+\n");
       printf
          (" |                                       MENU                                   |\n");
       printf
          (" +------------------------------------------------------------------------------+\n");
       printf
          (" |                                                                              |\n");
       printf
          (" |                            [1] Creer une tache                               |\n");
       printf
          (" |                                                                              |\n");
       printf
          (" |                     [2] Regler l'heure de reboot du PC                       |\n");
       printf
          (" |                                                                              |\n");
       printf
          (" |                           [3] Supprimer les taches                           |\n");
       printf
          (" |                                                                              |\n");
       printf
          (" +------------------------------------------------------------------------------+\n\n");
       printf ("                                   Choix (1/2) : ");
     
       scanf ("%d", &choix);
       purge ();
     
       if (choix == 1)
       {
          system ("@title AJOUT DE TACHES");
          system ("@MODE CON lines=8 cols=83");
          system ("@color 19");
     
          printf
             ("\n +------------------------------------------------------------------------------+\n");
          printf
             (" |                        REGLAGE DE L'HEURE D'EXECUTION                        |\n");
          printf
             (" +------------------------------------------------------------------------------+\n");
          printf
             (" |       Rentrez l'information au format suivant -> heure:min  ex 08:34         |\n");
          printf
             (" +------------------------------------------------------------------------------+\n\n");
          printf ("                      valeur : ");
     
          fgets (HM, sizeof HM, stdin);
          clean (HM);
     
          printf
             (" +------------------------------------------------------------------------------+\n");
          printf
             (" |                        CHEMIN D'EXECUTION DE LA TACHE                        |\n");
          printf
             (" +------------------------------------------------------------------------------+\n");
          printf
             (" |                 exemple :   C:\\DOS1\\DOS2\nom_fichier.***                     |\n");
          printf
             (" +------------------------------------------------------------------------------+\n\n");
          printf ("                      valeur : ");
          fgets (CHEMIN, sizeof CHEMIN, stdin);
          clean (CHEMIN);
     
          system ("title CREATION TACHES PLANIFIEES");
          system ("MODE CON lines=15 cols=83");
     
          sprintf (commande_AT, " AT %s /EVERY:l,ma,me,j,v,s,d %s ", HM, CHEMIN);
          fprintf (taches, " AT %s /EVERY:l,ma,me,j,v,s,d %s ", HM, CHEMIN);
          system (commande_AT);
          fclose (taches);
       }
     
       if (choix == 2)
       {
          char HR[5];
          char REBOOT[999];
     
          system ("@title HEURE DE REBOOT");
          system ("@MODE CON lines=9 cols=83");
     
          printf
             ("\n +------------------------------------------------------------------------------+\n");
          printf
             (" |                          REGLAGE DE L'HEURE DE REBOOT                        |\n");
          printf
             (" +------------------------------------------------------------------------------+\n");
          printf
             (" |       Rentrez l'information au format suivant -> heure:min  ex 08:34         |\n");
          printf
             (" +------------------------------------------------------------------------------+\n\n");
          printf ("                            valeur : ");
          fgets (HR, sizeof HM, stdin);
          clean (HR);
     
          sprintf (REBOOT,
                   "@AT %s /INTERACTIVE /EVERY:l,ma,me,j,v,s,d Shutdown -r", HR);
          fprintf (taches,
                   "@AT %s /INTERACTIVE /EVERY:l,ma,me,j,v,s,d Shutdown -r ", HR);
          system (REBOOT);
          fclose (taches);
     
          system ("@title CREATION TACHES PLANIFIEES");
          system ("@MODE CON lines=15 cols=83");
     
       }
     
       if (choix == 3)
       {
     
          system ("@title SUPPRESSION DE TACHES");
          system ("@MODE CON lines=5 cols=83");
     
          printf
             ("\n +------------------------------------------------------------------------------+\n");
          printf
             (" |                        CONFIRMATION DE LA SUPPRESSION                        |\n");
          printf
             (" +------------------------------------------------------------------------------+\n\n");
          printf ("                              valeur (1/2): ");
          scanf ("%d", &validation);
          purge ();
          if (validation == 1)
          {
             system ("@AT /DELETE /YES");
             printf
                ("\n +------------------------------------------------------------------------------+\n");
             printf
                (" |                              TACHES SUPPRIMEES                               |\n");
             printf
                (" +------------------------------------------------------------------------------+\n\n");
          }
     
          else
          {
             system ("exit");
          }
     
          system ("@title CREATION TACHES PLANIFIEES");
          system ("@MODE CON lines=15 cols=83");
       }
     
       if (choix == 3)
       {
          system ("exit");
       }
     
    }
     
    //-----< FONCTION PRINCIPALE >-----//
     
    int main (void)
    {
       AFFICHAGE_DE_LA_CMD ();
     
       while (1)
       {
          MENU ();
       }
     
       system ("exit");
    }
    Pas de Wi-Fi à la maison : CPL

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

Discussions similaires

  1. garder deux valeurs avec GET
    Par hugodu28 dans le forum Langage
    Réponses: 3
    Dernier message: 11/07/2012, 09h45
  2. Problème de test de valeur en GET
    Par Kuchiki Byakuya dans le forum Langage
    Réponses: 2
    Dernier message: 02/04/2011, 21h35
  3. [AJAX] Envoyer une valeur par get avec AJAX
    Par beegees dans le forum AJAX
    Réponses: 1
    Dernier message: 21/03/2009, 12h57
  4. [Système] Changer la valeur d'une variable GET
    Par toddy_101 dans le forum Langage
    Réponses: 13
    Dernier message: 31/01/2007, 14h59
  5. Fonction Get() renvoyant les mauvaises valeurs
    Par jairbubbles dans le forum XML
    Réponses: 1
    Dernier message: 20/11/2006, 12h33

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