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 :

Problème de condition


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Mars 2010
    Messages
    52
    Détails du profil
    Informations personnelles :
    Âge : 31
    Localisation : France

    Informations forums :
    Inscription : Mars 2010
    Messages : 52
    Par défaut Problème de condition
    salut tout les monde voila je suis nouveau mais j'ai pas pu voir une section présentation...
    vous ne m'en voudrez pas si mon premier sujet est pour demander de l'aide

    voila le problème:
    je travail sur un projet qui est un "challenge" dedans il y à des conditions (if/else normale quoi :p ) mais la je tombe sur un problème
    lorsque je met plusieurs conditions dans une seul je trouve des erreurs mais elle ne sont pas très précises .
    je vous poste la source en entière car certaine conditions doivent jouer sur l'erreur

    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
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    #include <stdio.h>
    #include <stdlib.h>
    #include <FMOD/fmod.h>
    #include <time.h>
    #include <windows.h>
    #include <string.h>
    #define CLEARSCREEN "clrscr" 
    BOOL SetConsoleSizeXY(HANDLE hStdout, int iWidth, int iHeight)
    {
     CONSOLE_SCREEN_BUFFER_INFO info;
     COORD      coordMax;
     
     coordMax = GetLargestConsoleWindowSize(hStdout);
     
     if (iHeight > coordMax.Y) iHeight = coordMax.Y;
     
     if (iWidth > coordMax.X) iWidth = coordMax.X;
     
     if (!GetConsoleScreenBufferInfo(hStdout, &info)) return FALSE;
     
    /* - hauteur - */
        info.srWindow.Left = 0;        
        info.srWindow.Right = info.dwSize.X - 1;               
        info.srWindow.Top = 0;
        info.srWindow.Bottom = iHeight - 1;         
     
     if (iHeight < info.dwSize.Y)
     {
      if (!SetConsoleWindowInfo(hStdout, TRUE, &info.srWindow))
       return FALSE;
     
      info.dwSize.Y = iHeight;
     
      if (!SetConsoleScreenBufferSize(hStdout, info.dwSize))
       return FALSE;
        }
        else if (iHeight > info.dwSize.Y)
        {
      info.dwSize.Y = iHeight;
     
      if (!SetConsoleScreenBufferSize(hStdout, info.dwSize))
       return FALSE;
     
      if (!SetConsoleWindowInfo(hStdout, TRUE, &info.srWindow))
       return FALSE;
        }
     
     if (!GetConsoleScreenBufferInfo(hStdout, &info))
      return FALSE;
     
    /* --- largeur - */
     info.srWindow.Left = 0;        
     info.srWindow.Right = iWidth - 1;
     info.srWindow.Top = 0;
     info.srWindow.Bottom = info.dwSize.Y - 1;              
     
     if (iWidth < info.dwSize.X)
     {
      if (!SetConsoleWindowInfo(hStdout, TRUE, &info.srWindow))
       return FALSE;
     
      info.dwSize.X = iWidth;
     
      if (!SetConsoleScreenBufferSize(hStdout, info.dwSize))
       return FALSE;
     }
     else if (iWidth > info.dwSize.X)
     {
      info.dwSize.X = iWidth;
     
      if (!SetConsoleScreenBufferSize(hStdout, info.dwSize))
       return FALSE;
     
      if (!SetConsoleWindowInfo(hStdout, TRUE, &info.srWindow))
       return FALSE;
     }
     
     return TRUE;
    }
     
    static void purger(void)
    {
        int c;
     
        while ((c = getchar()) != '\n' && c != EOF)
        {}
    }
     
    static void clean (char *chaine)
    {
        char *p = strchr(chaine, '\n');
     
        if (p)
        {
            *p = 0;
        }
     
        else
        {
            purger();
        }
    }
     
     
     
      void Color(int couleurDuTexte,int couleurDeFond);
     
     
    int main(int argc, char *argv[])
    {//main open
        char chaine[40];
        CONSOLE_SCREEN_BUFFER_INFO info;
        HANDLE hStdout;
        hStdout = GetStdHandle (STD_OUTPUT_HANDLE);
     
        SetConsoleSizeXY(hStdout, 100, 50);
     FSOUND_Init(44100, 32, 0);
    FSOUND_SAMPLE *registr = NULL;
    FSOUND_SAMPLE *hahha = NULL; 
    registr = FSOUND_Sample_Load(FSOUND_FREE, "registrationcomplete.wav", 0, 0, 0);
    hahha = FSOUND_Sample_Load(FSOUND_FREE, "hahha.wav", 0, 0, 0);
    int compteur = 0;
    Color(15,1);
    printf("\nChargement du Challenge....\n");
        sleep(5000);
        system("cls");
    	printf("Bienvenu dans se challenge qui est comme ... un mini OS.\n\n");
    printf("le but est de derober un document secret qui est lui meme proteger par l'administrateur.\n\n");
    printf("le document secret detient un code qui vous permettera de valider se challenge.\n\n");
    printf("\n\n\napuyez sur une touche pour commencer\n");
    getch();
    system("CLS");
        /*int pass = 54768;*/
        char acc[] = "dieu";
        char cd[] = "cd Management";
        char cda[] = "cd Personal Document";
        char cdb[] = "cd Secret Document";
        char cdc[] = "cd Systeme";
        char cdd[] = "cd Corbeille";
        char cde[] = "ACDC";
    Menu:
         system("CLS");    
    printf("******************************************************\n");
    printf("*                                                    *\n");
    printf("*             Systeme Administrator                  *\n");
    printf("*                                                    *\n");
    printf("******************************************************\n");
     
    printf("\n\n                                                                 vous etes dans la racine\n\n");
    printf("\nPour se rendre dans different repertoir utilisez la commande:\n\ncd le nom du repertoir\n\nexemple: cd Personal Document\n\n\n");
     
    		printf("		Racine                                                        \n");  
    		printf("	     ______|______                                                    \n"); 
    		printf("	    |             |                      Management                   \n");   
    		printf("	    |_____________|                      _____|____                   \n"); 
         		printf("	       |   |   |                        |          |                  \n");  
                    printf("	       |   |   |-------[Secure]---------|          |                  \n");  
                    printf("               |   |                            |__________|                  \n"); 
    		printf("	       |   |				                              \n");  
                    printf("               |   |                                                          \n");  
    		printf("	       |   |                             _________                    \n");  
                    printf("               |   |                            |         |                   \n");  
                    printf("               |   |----------------------------|         |- Personal Document\n");  
    		printf("	       |                                |_________|                   \n");  
    		printf("	       |                                                              \n");  
                    printf("               |                                                              \n");   
                    printf("               |                                                              \n");   
                    printf("               |                                 _________                    \n");  
                    printf("               |                                |         |                   \n");   
    		printf("	       |------------[Secure]------------|         |- Secret Document  \n");   
    		printf("						|_________|                   \n");   
     
     
     
    printf("\n\nterminal : ");
        fgets(chaine, sizeof chaine, stdin);
        clean(chaine);
     
     
     
     
      if ( strcmp( chaine, "cd Management" ) == 0 ) 
    {             // cd Management open                                
         printf("\n\nWhat's the magic Word ??\n");
     printf("\n ");                               
        fgets(chaine, sizeof chaine, stdin);      
        clean(chaine);                             
     
      if ( strcmp( chaine, "dieu" ) == 0 )
     { //dieu ok open
      system("CLS" );
      printf ("ok\n");
      FSOUND_PlaySound(FSOUND_FREE, registr);
      printf("\nLoading...\n");
      sleep(2000);
    Management:
      system("CLS");
      printf("\n                                         vous êtes dans Management\n\n");
     
      printf("\n");
     
    printf("                            Management        \n");
    printf("                      __________|__________   \n");
    printf("                     |                     |  \n");
    printf("                     |                     |  \n"); 
    printf("                     |_____________________|  \n");
    printf("                           |          |       \n");
    printf("                           |          |       \n");
    printf("                           |          |       \n");
    printf("                         __|__      __|__     \n");
    printf("                        |     |    |     |    \n");
    printf("                        |_____|    |_____|    \n");
    printf("                           |          |       \n");
    printf("                        Systeme    Corbeille  \n");
     
    printf("\n\nterminal : ");
        fgets(chaine, sizeof chaine, stdin);
        clean(chaine);
     
    if ( strcmp( chaine, "cd Systeme" ) == 0 )  
       {           // cd systeme open          
    system("CLS");
    printf("\n\n Systeme information:\n\n")
    printf("\n\n System Administration was created in console mode for a challenge.\n");
    printf("However it seems realistic that the challenger is in a real situation.\n");
    printf("The challenge represents a small OS has been coded by Addict of HFF for anyone wishing to practice in the art of hacking.\n");
    printf("This challenge fun, realistic and entertaining puzzle contains a small bit encryption and access to some place that I name system administration system simulated.\n");
    printf("You've already managed to penetrate the system of administration good luck for the future.\n");
    getch();
    goto Management;
       } //cd system close
     
     
     
    else if ( strcmp( chaine, "cd Corbeille" ) == 0 )
       {          // cd corbeille open                              
    system("CLS");
    printf("\nCryptage ON\n\n");
    printf("\nEron`Eron`Eron`Eron`Eron`Eron`Eron`Eron`Eron`1010110011011100`Eron`Eron`Eron`Eron`\n");
    getch();
    goto Management;
     
        } // corbeille close
     
     } // dieu close
     
     
     
     
     
     
    else if ( strcmp( chaine, "dieu" ) != 0 )
      { //nondieu open
      system("CLS" ); 
     
      while (compteur < 60)
    {
        printf("You didn't say the Magic word !!! HAHAHA !!!\n");
        compteur++;
    }
     
     
    FSOUND_PlaySound(FSOUND_FREE, hahha);
    getch();
    goto Menu;
      } //nodieu close
     
    } // management close
     
     
     
     
     
     
        else if ( strcmp( chaine, "cd Personal Document" ) == 0 ) //cd personal open
         {
              printf("test test");
              getch();
              } //  cd personal close 
     
     
     
     
     
     
     
        else if ( strcmp( chaine, "cd Secret Document" ) == 0 ) 
         { // cd secret open
             printf("\nwhat's the password ? (in Majuscule)\n");
         printf("\n ");
        fgets(chaine, sizeof chaine, stdin);
        clean(chaine); 
     
      if ( strcmp( chaine, "ACDC" ) == 0 )
              { //acdc open
      system("CLS" );
      printf ("ok\n");
      FSOUND_PlaySound(FSOUND_FREE, registr);
      printf("\nLoading...\n");
      sleep(2000);
      system("CLS");
      printf("\npress ENTER\n");
      getch();
    } //acdc close
    else if ( strcmp( chaine, "ACDC" ) != 0 )
      { //naacdc open
      system("CLS" ); 
     
      while (compteur < 60)
    {
        printf("You didn't say the Magic word !!! HAHAHA !!!\n");
        compteur++;
    }
     
     
    FSOUND_PlaySound(FSOUND_FREE, hahha);
    getch();
    goto Menu;    
      }  //naacdc close
     
         }//  secret doc close
     
     
     
     
    getch();	
      FSOUND_Sample_Free(registr);
      FSOUND_Sample_Free(hahha);
     	FSOUND_Close();
      return 0;
    } // main close
     
     
    void Color(int couleurDuTexte,int couleurDeFond) // fonction d'affichage de couleurs
    {
            HANDLE H=GetStdHandle(STD_OUTPUT_HANDLE);
            SetConsoleTextAttribute(H,couleurDeFond*16+couleurDuTexte);
    }
    le code marchait bien jusqu'à que je remplace cette partie
    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
     
      if ( strcmp( chaine, "cd Management" ) == 0 ) 
    {             // cd Management open                                
         printf("\n\nWhat's the magic Word ??\n");
     printf("\n ");                               
        fgets(chaine, sizeof chaine, stdin);      
        clean(chaine);                             
     
      if ( strcmp( chaine, "dieu" ) == 0 )
     { //dieu ok open
      system("CLS" );
      printf ("ok\n");
      FSOUND_PlaySound(FSOUND_FREE, registr);
      printf("\nLoading...\n");
      sleep(2000);
    system("CLS")
    printf("test");
    getch();
    }
    par celle la

    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
      if ( strcmp( chaine, "cd Management" ) == 0 ) 
    {             // cd Management open                                
         printf("\n\nWhat's the magic Word ??\n");
     printf("\n ");                               
        fgets(chaine, sizeof chaine, stdin);      
        clean(chaine);                             
     
      if ( strcmp( chaine, "dieu" ) == 0 )
     { //dieu ok open
      system("CLS" );
      printf ("ok\n");
      FSOUND_PlaySound(FSOUND_FREE, registr);
      printf("\nLoading...\n");
      sleep(2000);
    Management:
      system("CLS");
      printf("\n                                         vous êtes dans Management\n\n");
     
      printf("\n");
     
    printf("                            Management        \n");
    printf("                      __________|__________   \n");
    printf("                     |                     |  \n");
    printf("                     |                     |  \n"); 
    printf("                     |_____________________|  \n");
    printf("                           |          |       \n");
    printf("                           |          |       \n");
    printf("                           |          |       \n");
    printf("                         __|__      __|__     \n");
    printf("                        |     |    |     |    \n");
    printf("                        |_____|    |_____|    \n");
    printf("                           |          |       \n");
    printf("                        Systeme    Corbeille  \n");
     
    printf("\n\nterminal : ");
        fgets(chaine, sizeof chaine, stdin);
        clean(chaine);
     
    if ( strcmp( chaine, "cd Systeme" ) == 0 )  
       {           // cd systeme open          
    system("CLS");
    printf("\n\n Systeme information:\n\n")
    printf("\n\n System Administration was created in console mode for a challenge.\n");
    printf("However it seems realistic that the challenger is in a real situation.\n");
    printf("The challenge represents a small OS has been coded by Addict of HFF for anyone wishing to practice in the art of hacking.\n");
    printf("This challenge fun, realistic and entertaining puzzle contains a small bit encryption and access to some place that I name system administration system simulated.\n");
    printf("You've already managed to penetrate the system of administration good luck for the future.\n");
    getch();
    goto Management;
       } //cd system close
     
     
     
    else if ( strcmp( chaine, "cd Corbeille" ) == 0 )
       {          // cd corbeille open                              
    system("CLS");
    printf("\nCryptage ON\n\n");
    printf("\nEron`Eron`Eron`Eron`Eron`Eron`Eron`Eron`Eron`1010110011011100`Eron`Eron`Eron`Eron`\n");
    getch();
    goto Management;
     
        } // corbeille close
     
     } // dieu close
     
     
     
     
     
     
    else if ( strcmp( chaine, "dieu" ) != 0 )
      { //nondieu open
      system("CLS" ); 
     
      while (compteur < 60)
    {
        printf("You didn't say the Magic word !!! HAHAHA !!!\n");
        compteur++;
    }
     
     
    FSOUND_PlaySound(FSOUND_FREE, hahha);
    getch();
    goto Menu;
      } //nodieu close
     
    } // management close
    voila les erreurs trouvaient:
    C:\Dev-Cpp\challenge1\subs\main.c In function `main':
    224 C:\Dev-Cpp\challenge1\subs\main.c syntax error before "printf"
    C:\Dev-Cpp\challenge1\subs\Makefile.win [Build Error] [main.o] Error 1

    la 2ème erreur est étrange car lorsque j'enlève le texte c'est getch(); qui est ciblé et un ci de suite

    Merci à ceux qui pourrons m'aider dans se projet farfelu
    HS: désolé si j'ai fait des fautes

  2. #2
    Membre émérite
    Avatar de Pouet_forever
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    671
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2009
    Messages : 671
    Par défaut
    Il te manque un point virgule à la ligne d'avant.
    Ton code est plein de goto à tout va, pas indenté, comment veut-tu t'y retrouver là-dedans ?
    On évite généralement d'utiliser les goto en C pour éviter les codes incompréhensibles !
    Une bonne indentation t'aidera aussi à lire ton code et à retrouver plus facilement tes erreurs.

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Mars 2010
    Messages
    52
    Détails du profil
    Informations personnelles :
    Âge : 31
    Localisation : France

    Informations forums :
    Inscription : Mars 2010
    Messages : 52
    Par défaut


    je comprend même pas comment j'ai fait pour ne pas voir ce ";"

    je te remercie

    effectivement mon code est pas très propre je l'ais commencé hier et je conte bien arranger ça lorsqu'il sera fini

    les goto vont disparaitre c'est juste pour tester les sous options sans devoir redémarrer le programme à chaque fois

  4. #4
    Modérateur
    Avatar de Obsidian
    Homme Profil pro
    Chercheur d'emploi
    Inscrit en
    Septembre 2007
    Messages
    7 480
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Chercheur d'emploi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2007
    Messages : 7 480
    Par défaut
    Citation Envoyé par AddicTion Voir le message


    je comprend même pas comment je n'est pas fait pour voir ce ";"
    Rassure-toi, tout le monde est passé par là, même les meilleurs !

Discussions similaires

  1. [débutant] problème de condition dans une requete
    Par banker dans le forum Access
    Réponses: 5
    Dernier message: 22/03/2006, 13h52
  2. Réponses: 7
    Dernier message: 27/02/2006, 18h04
  3. [Debutant]Problème de condition
    Par ghan77 dans le forum Langage
    Réponses: 9
    Dernier message: 13/12/2005, 15h20
  4. Problème de condition, je flanche..
    Par KibitO dans le forum Langage
    Réponses: 13
    Dernier message: 11/11/2005, 12h57
  5. Réponses: 6
    Dernier message: 17/08/2005, 12h38

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