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 :

Jeu othello - erreurs à la compilation


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Futur Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2014
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2014
    Messages : 3
    Par défaut Jeu othello - erreurs à la compilation
    bonsoir a tous j'ai un problème avec mon code source quand je le compile il m"affiche que j'ai deux erreurs que je n'arrive pas a trouver et tous truc que je modifie change tout le reste quelqu'un pourrai-t-il m'aider c'est pour un jeu othello que je fais sur codeblocks

    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
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    #include <stdio.h>
    #include <ctype.h>
     
     
     
    void affiche_tableau()
    {
      char tab [8][8] = { 0 };  /* The board           */
      int moves[0][0] = { 0 };    /* Valid moves         */
      int row = 0;                      /* Board row index     */
      int col = 0;                      /* Board column index  */
      int no_of_games = 0;              /* Number of games     */
      int no_of_moves = 0;              /* Count of moves      */
      int invalid_moves = 0;            /* Invalid move count  */
      int comp_score = 0;               /* Computer score      */
      int user_score = 0;               /* Player score        */
      char y = 0;                       /* Column letter       */
      int x = 0;                        /* Row number          */
      char again = 0;                   /* Replay choice input */
      int player = 0;                   /* Player indicator    */
     
       printf("\nREVERSI\n\n");
      printf("You can go first on the first game, then we will take turns.\n");
      printf("   You will be white - (0)\n   I will be black   - (1).\n");
      printf("Select a square for your move by typing a digit for the row\n "
        "and a letter for the column with no spaces between.\n");
      printf("\nGood luck!  Press Enter to start.\n");
      scanf("%c", &again);
     
       /* Prompt for how to play - as before */
     
       /* The main game loop */
       do
       {
         /* On even games the player starts; */
         /* on odd games the computer starts */
         player = ++no_of_games % 2;
         no_of_moves = 4;                /* Starts with four counters */
     
         /* Blank all the board squares */
         for(row = 0; row < 8; row++)
           for(col = 0; col < 8; col++)
             tab[row][col] = ' ';
     
         /* Place the initial four counters in the center */
         tab[8/2 - 1][8/2 - 1] = tab[8/2][8/2] = '0';
         tab[8/2 - 1][8/2] = tab[8/2][8/2 - 1] = '1';
     
         /* The game play loop */
         do
         {
           display(tab);             /* Display the board  */
           if(player++ % 2)
           { /*   It is the player's turn                    */
             if(valid_moves(tab, moves, '0'))
             {
               /* Read player moves until a valid move is entered */
               for(;;)
               {
                 fflush(stdin);              /* Flush the keyboard buffer */
                 printf("Please enter your move (row column): ");
                 scanf("%d%c", &x, &y);              /* Read input        */
                 y = tolower(y) - 'a';         /* Convert to column index */
                 x--;                          /* Convert to row index    */
                 if( x>=0 && y>=0 && x<8 && y<8 && moves[x][y])
                 {
                   make_move(tab, x, y, '0');
                   no_of_moves++;              /* Increment move count */
                   break;
                 }
                 else
                   printf("Not a valid move, try again.\n");
               }
             }
             else                              /* No valid moves */
               if(++invalid_moves<2)
               {
                 fflush(stdin);
                 printf("\nYou have to pass, press return");
                 scanf("%c", &again);
               }
               else
                 printf("\nNeither of us can go, so the game is over.\n");
           }
           else
           { /* It is the computer's turn                    */
             if(valid_moves(tab, moves, '1')) /* Check for valid moves */
             {
               invalid_moves = 0;               /* Reset invalid count   */
               computer_move(tab, moves, '1');
               no_of_moves++;                   /* Increment move count  */
             }
             else
             {
               if(++invalid_moves<2)
                 printf("\nI have to pass, your go\n"); /* No valid move */
               else
                 printf("\nNeither of us can go, so the game is over.\n");
             }
           }
         }while(no_of_moves < 8*8 && invalid_moves<2);
     
         /* Game is over */
         display(tab);  /* Show final board */
     
         /* Get final scores and display them */
         comp_score = user_score = 0;
         for(row = 0; row < 8; row++)
           for(col = 0; col < 8; col++)
           {
             comp_score += tab[row][col] == '1';
             user_score += tab[row][col] == '0';
           }
         printf("The final score is:\n");
         printf("Computer %d\n    User %d\n\n", comp_score, user_score);
     
         fflush(stdin);               /* Flush the input buffer */
         printf("Do you want to play again (y/n): ");
         scanf("%c", &again);         /* Get y or n             */
       }while(tolower(again) == 'y'); /* Go again on y          */
     
       printf("\nGoodbye\n");
    }
     
    /***********************************************
     * Function to display the board in it's       *
     * current state with row numbers and column   *
     * letters to identify squares.                *
     * Parameter is the board array.               *
     ***********************************************/
    void display(char tab[][8])
    {
       int row  = 0;          /* Row index      */
       int col = 0;           /* Column index   */
       char col_label = 'a';  /* Column label   */
     
       printf("\n ");         /* Start top line */
       for(col = 0 ; col<8 ;col++)
         printf("   %c", col_label+col); /* Display the top line */
       printf("\n");                     /* End the top line     */
     
       /* Display the intermediate rows */
       for(row = 0; row < 8; row++)
       {
         printf("  +");
         for(col = 0; col<8; col++)
           printf("---+");
         printf("\n%2d|",row + 1);
     
         for(col = 0; col<8; col++)
           printf(" %c |", tab[row][col]);  /* Display counters in row */
         printf("\n");
       }
     
       printf("  +");                  /* Start the bottom line   */
       for(col = 0 ; col<8 ;col++)
         printf("---+");               /* Display the bottom line */
       printf("\n");                   /* End the bottom  line    */
    }
     
    /***********************************************
    /* Calculates which squares are valid moves    *
     * for player. Valid moves are recorded in the *
     * moves array - 1 indicates a valid move,     *
     * 0 indicates an invalid move.                *
     * First parameter is the board array          *
     * Second parameter is the moves array         *
     * Third parameter identifies the player       *
     * to make the move.                           *
     * Returns valid move count.                   *
     ***********************************************/
    int valid_moves(char tab[][8], int moves[][8], char player)
    {
       int rowdelta = 0;     /* Row increment around a square    */
       int coldelta = 0;     /* Column increment around a square */
       int row = 0;          /* Row index                        */
       int col = 0;          /* Column index                     */
       int x = 0;            /* Row index when searching         */
       int y = 0;            /* Column index when searching      */
       int no_of_moves = 0;  /* Number of valid moves            */
     
       /* Set the opponent            */
       char opponent = (player == '0')? '1' : '0';
     
       /* Initialize moves array to zero */
       for(row = 0; row < 8; row++)
         for(col = 0; col < 8; col++)
           moves[row][col] = 0;
     
       /* Find squares for valid moves.                           */
       /* A valid move must be on a blank square and must enclose */
       /* at least one opponent square between two player squares */
       for(row = 0; row < 8; row++)
         for(col = 0; col < 8; col++)
         {
           if(tab[row][col] != ' ')   /* Is it a blank square?  */
             continue;                  /* No - so on to the next */
     
           /* Check all the squares around the blank square  */
           /* for the opponents counter                      */
           for(rowdelta = -1; rowdelta <= 1; rowdelta++)
             for(coldelta = -1; coldelta <= 1; coldelta++)
             {
               /* Don't check outside the array, or the current square */
               if(row + rowdelta < 0 || row + rowdelta >= 8 ||
                  col + coldelta < 0 || col + coldelta >= 8 ||
                                           (rowdelta==0 && coldelta==0))
                 continue;
     
               /* Now check the square */
               if(tab[row + rowdelta][col + coldelta] == opponent)
               {
                 /* If we find the opponent, move in the delta direction  */
                 /* over opponent counters searching for a player counter */
                 x = row + rowdelta;                /* Move to          */
                 y = col + coldelta;                /* opponent square  */
     
                 /* Look for a player square in the delta direction */
                 for(;;)
                 {
                   x += rowdelta;                  /* Go to next square */
                   y += coldelta;                  /* in delta direction*/
     
                   /* If we move outside the array, give up */
                   if(x < 0 || x >= 8 || y < 0 || y >= 8)
                     break;
     
                   /* If we find a blank square, give up */
                   if(tab[x][y] == ' ')
                     break;
                    /*  If the square has a player counter */
                    /*  then we have a valid move          */
                   if(tab[x][y] == player)
                   {
                     moves[row][col] = 1;   /* Mark as valid */
                     no_of_moves++;         /* Increase valid moves count */
                     break;                 /* Go check another square    */
                   }
                 }
               }
             }
         }
       return no_of_moves;
    }
     
    /************
     * Finds the best move for the computer. This is the move for      *
     * which the opponent's best possible move score is a minimum.     *
     * First parameter is the board array.                             *
     * Second parameter is the moves array containing valid moves.     *
     * Third parameter identifies the computer.                        *
     ************/
    void computer_move(char tab[][8], int moves[][8], char player)
    {
       int row = 0;                          /* Row index               */
       int col = 0;                          /* Column index            */
       int best_row = 0;                     /* Best row index          */
       int best_col = 0;                     /* Best column index       */
       int i = 0;                            /* Loop index              */
       int j = 0;                            /* Loop index              */
       int new_score = 0;                    /* Score for current move  */
       int score = 100;                      /* Minimum opponent score  */
       char temp_tab[8][8];          /* Local copy of board     */
       int temp_moves[8][8];           /* Local valid moves array */
       char opponent = (player == '0')? '1' : '0'; /* Identify opponent */
     
       /* Go through all valid moves */
       for(row = 0; row < 8; row++)
         for(col = 0; col < 8; col++)
         {
           if(moves[row][col] == 0)
             continue;
     
           /* First make copies of the board and moves arrays */
           for(i = 0; i < 8; i++)
             for(j = 0; j < 8; j++)
               temp_tab[i][j] = tab[i][j];
     
           /* Now make this move on the temporary board */
           make_move(temp_tab, row, col, player);
     
           /* find valid moves for the opponent after this move */
           valid_moves(temp_tab, temp_moves, opponent);
     
           /* Now find the score for the opponents best move */
           new_score = best_move(temp_tab, temp_moves, opponent);
     
           if(new_score<score)    /* Is it worse?           */
           {                      /* Yes, so save this move */
             score = new_score;   /* Record new lowest opponent score */
             best_row = row;  /* Record best move row             */
             best_col = col;  /* and column                       */
           }
         }
     
       /* Make the best move */
       make_move(tab, best_row, best_col, player);
    }
     
    /************
     * Calculates the score for the current board position for the     *
     * player. player counters score +1, opponent counters score -1    *
     * First parameter is the board array                              *
     * Second parameter identifies the player                          *
     * Return value is the score.                                      *
     ************/
    int get_score(char tab[][8], char player)
    {
       int score = 0;      /* Score for current position */
       int row = 0;        /* Row index                  */
       int col = 0;        /* Column index               */
       char opponent = player == '0' ? '1' : '0';  /* Identify opponent */
     
       /* Check all board squares */
       for(row = 0; row < 8; row++)
         for(col = 0; col < 8; col++)
       {
         score -= tab[row][col] == opponent; /* Decrement for opponent */
         score += tab[row][col] == player;   /* Increment for player   */
       }
       return score;
    }
     
    /************
     * Calculates the score for the best move out of the valid moves   *
     * for player in the current position.                             *
     * First parameter is the board array                              *
     * Second parameter is the moves array defining valid moves.       *
     * Third parameter identifies the player                           *
     * The score for the best move is returned                         *
     ************/
    int best_move(char tab[][8], int moves[][8], char player)
    {
       int row = 0;     /* Row index    */
       int col = 0;     /* Column index */
       int i = 0;       /* Loop index   */
       int j = 0;       /* Loop index   */
     
       char opponent = player=='0'?'1':'0'; /* Identify opponent */
     
       char new_tab[8][8] = { 0 };  /* Local copy of board    */
     
       int score = 0;                       /* Best score             */
       int new_score = 0;                   /* Score for current move */
     
       /* Check all valid moves to find the best */
       for(row = 0 ; row<8 ; row++)
         for(col = 0 ; col<8 ; col++)
         {
           if(!moves[row][col])             /* Not a valid move?      */
             continue;                      /* Go to the next         */
     
           /* Copy the board */
           for(i = 0 ; i<8 ; i++)
             for(j = 0 ; j<8 ; j++)
               new_tab[i][j] = tab[i][j];
     
           /* Make move on the board copy */
           make_move(new_tab, row, col, player);
     
           /* Get score for move */
           new_score = get_score(new_tab, player);
     
           if(score<new_score)         /* Is it better?               */
                   score = new_score;  /* Yes, save it as best score  */
         }
       return score;                   /* Return best score           */
    }
     
    /*************
     * Makes a move. This places the counter on a square,and reverses   *
     * all the opponent's counters affected by the move.                *
     * First parameter is the board array.                              *
     * Second and third parameters are the row and column indices.      *
     * Fourth parameter identifies the player.                          *
     *************/
    void make_move(char tab[][8], int row, int col, char player)
    {
       int rowdelta = 0;                   /* Row increment              */
       int coldelta = 0;                   /* Column increment           */
       int x = 0;                          /* Row index for searching    */
       int y = 0;                          /* Column index for searching */
       char opponent = (player == '0')? '1' : '0';  /* Identify opponent */
     
       tab[row][col] = player;           /* Place the player counter   */
     
       /* Check all the squares around this square */
       /* for the opponents counter                */
       for(rowdelta = -1; rowdelta <= 1; rowdelta++)
         for(coldelta = -1; coldelta <= 1; coldelta++)
         {
           /* Don't check off the board, or the current square */
           if(row + rowdelta < 0 || row + rowdelta >= 8 ||
              col + coldelta < 0 || col + coldelta >= 8 ||
                                   (rowdelta==0 && coldelta== 0))
             continue;
     
           /* Now check the square */
           if(tab[row + rowdelta][col + coldelta] == opponent)
           {
             /* If we find the opponent, search in the same direction */
             /* for a player counter                                  */
             x = row + rowdelta;        /* Move to opponent */
             y = col + coldelta;        /* square           */
     
             for(;;)
             {
               x += rowdelta;           /* Move to the      */
               y += coldelta;           /* next square      */
     
               /* If we are off the board give up */
               if(x < 0 || x >= 8 || y < 0 || y >= 8)
                 break;
     
               /* If the square is blank give up */
               if(tab[x][y] == ' ')
                 break;
     
               /* If we find the player counter, go backwards from here */
               /* changing all the opponents counters to player         */
               if(tab[x][y] == player)
               {
                 while(tab[x-=rowdelta][y-=coldelta]==opponent) /* Opponent? */
                   tab[x][y] = player;    /* Yes, change it */
                 break;                     /* We are done    */
               }
             }
           }
         }
    }

  2. #2
    Membre prolifique
    Avatar de Sve@r
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2006
    Messages
    12 835
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Février 2006
    Messages : 12 835
    Billets dans le blog
    1
    Par défaut
    Citation Envoyé par salifnb Voir le message
    bonsoir a tous
    Bonsoir

    Citation Envoyé par salifnb Voir le message
    j'ai un problème avec mon code source quand je le compile il m"affiche que j'ai deux erreurs que je n'arrive pas a trouver
    T'as raison. Surtout ne nous donnes pas les messages d'erreur du compilo, ça aurait été trop facile sinon.
    C'est vrai, c'est pas mal de nous mettre en plus un petit challenge "commencez par trouver le problème avant de proposer une solution"...

    Citation Envoyé par salifnb Voir le message
    et tous truc que je modifie change tout le reste
    Ah là là cette fameuse théorie des dominos... Que de tracas elle nous cause à tous...

    Citation Envoyé par salifnb Voir le message
    quelqu'un pourrai-t-il m'aider c'est pour un jeu othello que je fais sur codeblocks
    C'est la mode en ce moment Othello. C'est la seconde fois que je le vois ici et je l'ai vu sur un autre forum. Vous êtes tous dans la même classe ou quoi ???

    Citation Envoyé par salifnb Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    void affiche_tableau()
    {
      char tab [8][8] = { 0 };  /* The board           */
      int moves[0][0] = { 0 };    /* Valid moves         */
    On n'initialise pas un tableau 2D comme un tableau 1D...
    Mon Tutoriel sur la programmation «Python»
    Mon Tutoriel sur la programmation «Shell»
    Sinon il y en a pleins d'autres. N'oubliez pas non plus les différentes faq disponibles sur ce site
    Et on poste ses codes entre balises [code] et [/code]

  3. #3
    Futur Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2014
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2014
    Messages : 3
    Par défaut reponse
    euh desole mais je sais pas de qui tu parle mais je pense pas qu'on soit dans la meme classe mais bon il ya 2 erreur la premiere au niveau du {valid_move et du best_move}

  4. #4
    Membre émérite
    Avatar de Daïmanu
    Homme Profil pro
    Développeur touche à tout
    Inscrit en
    Janvier 2011
    Messages
    736
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur touche à tout

    Informations forums :
    Inscription : Janvier 2011
    Messages : 736
    Par défaut
    Citation Envoyé par salifnb Voir le message
    euh desole mais je sais pas de qui tu parle mais je pense pas qu'on soit dans la meme classe
    Sve@r parle de cette discussion qui date d'il y a une semaine, c'est pour ça qu'il dit que c'est « à la mode ».

    Citation Envoyé par salifnb Voir le message
    bon il ya 2 erreur la premiere au niveau du {valid_move et du best_move}
    On voudrait des vrais messages d'erreur pour t'aider, ceux indiqués par le compilateur, sans quoi on pourra pas vraiment t'aider

  5. #5
    Futur Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2014
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2014
    Messages : 3
    Par défaut voici les erreurs recenser par le compilateur
    voici ce que le compilateur me montre
    Images attachées Images attachées  

  6. #6
    Membre prolifique
    Avatar de Sve@r
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2006
    Messages
    12 835
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Février 2006
    Messages : 12 835
    Billets dans le blog
    1
    Par défaut
    Une fonction non déclarée est mise automatiquement int. Lorsque le compilo te voit utiliser display() en ligne 52 (fonction qu'il ne connait pas encore), il la positionne automatiquement en "int display()".
    Ensuite quand tu la déclares en void display() en ligne 173 il te dit qu'il y a un conflit de type puisqu'il la connait en tant qu'int.

    Pareil pour les autres...

    Autres détails: for (;;) c'est un peu moyen alors qu'il y a while (1) plus simple ; et tes fflush(stdin) sont absolument à proscrire.
    Mon Tutoriel sur la programmation «Python»
    Mon Tutoriel sur la programmation «Shell»
    Sinon il y en a pleins d'autres. N'oubliez pas non plus les différentes faq disponibles sur ce site
    Et on poste ses codes entre balises [code] et [/code]

  7. #7
    Expert éminent

    Femme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    5 202
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 5 202
    Par défaut
    Je trouve qu'il y a aussi plusieurs défauts structurels.

    Les fonctions ne sont pas déclarées en début de programme.
    En remédiant à cela, le main peut être la première fonction codée du fichier, ce qui est tout de même plus clair.

    Il n'y a pas non plus d'énumérations ou de constantes pour expliciter les valeurs magiques telles que 8, '0' et '1'.

    On peut aussi parler de l'absence de typedefs et d'une structure plateau.
    Par exemple:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    typedef char pion_t;
    static const pion_t PasDePion=' ', PionBlanc='1', PionNoir='0';
     
    struct plateau {
        pion_t cases[TAILLE_PLATEAU*TAILLE_PLATEAU];
        int score;//nombre de blancs - nombre de noirs.
        int coupsRestants;
    };
    Et surtout, quelque chose qui me semble extrêmement bizarre: int moves[0][0] = { 0 }; Un double tableau de 0 tableaux de 0 entiers chacun, avec un unique entier en guise d'initialiseurs.

    Si ton compilateur ne te maudis pas sur quatre générations (au moins), tu devrais songer à en changer.

    Un petit conseil présenté avec humour, mais sérieux:
    Tout message du compilateur est un cri de souffrance de sa part.
    Rectifie ton code pour le faire taire.
    Quand il se tait, c'est qu'il ne hurle plus si fort, il est temps de devenir plus attentif (c'est à dire, d'activer d'autres warnings)

Discussions similaires

  1. Erreur de compilation après modification du Uses
    Par DevelOpeR13 dans le forum Langage
    Réponses: 5
    Dernier message: 30/10/2007, 14h23
  2. Réponses: 2
    Dernier message: 23/09/2003, 14h32
  3. Réponses: 10
    Dernier message: 22/09/2003, 21h58
  4. Réponses: 4
    Dernier message: 27/08/2003, 21h34
  5. Réponses: 2
    Dernier message: 04/03/2003, 23h24

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