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
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TAILLE_PIECE 5
#define NB_PIECE_MAX 30
#define ZERO 48
#define UN 49
#define X_MAJ 88
#define ESPACE 32
char **piece_fichier ()
{
FILE *ptr_piece;
int i , j , num_piece = 0;
char ligne_piece [TAILLE_PIECE];
char piece [NB_PIECE_MAX] [TAILLE_PIECE];
ptr_piece = fopen ("piece.txt", "r");
while (!feof (ptr_piece))
{
fgets (ligne_piece, sizeof (ligne_piece), ptr_piece);
for (i=0 ; i<TAILLE_PIECE-1 ; i++)
{
if (ligne_piece [i] == ZERO)
{
piece [num_piece] [i] = ESPACE;
}
else if (ligne_piece [i] == UN)
{
piece [num_piece] [i] = X_MAJ;
}
}
num_piece ++;
}
for (j = 0 ; j < NB_PIECE_MAX-1 ; j++)
{
piece [j] [TAILLE_PIECE-1] = 0;
}
return piece; erreur : 41 I:\piece_fichier.c [Warning] return from incompatible pointer type
erreur : 41 I:\piece_fichier.c [Warning] function returns address of local variable
}
int main ()
{
char piece_retour [NB_PIECE_MAX] [TAILLE_PIECE];
int j;
piece_retour = piece_fichier (); erreur : 49 I:\piece_fichier.c incompatible types in assignment
for (j = 0 ; j < NB_PIECE_MAX-1 ; j++)
{
printf ("%s\n" , piece_retour [j]);
}
return 0;
} |
Partager