Bonjour,
désolé si c'est une question bete mais dans une procedure je récupère les info d'un fichier texte
cette procédure m'avait été proposée dans une une autre discussion et fonctionne mais maintenant dans une nouvelle procédure que j'ai créée je veux afficher ce que j'ai récupéré. j'ai le code suivant dans ma procédure:Code:
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 void RecuperationCarte(int **Recuperation) { struct stat buf; int n=0; FILE * FicTxt; int temp; if((FicTxt = fopen("map1.txt","rt")) == NULL) { printf("erreur"); exit(-1); } fstat(fileno(FicTxt),&buf); *Recuperation = malloc (buf.st_size); if ( *Recuperation == NULL ) { printf("erreur d'allocation"); fclose(FicTxt); exit(-1); } while((temp = fgetc(FicTxt))!=EOF) { (*Recuperation)[n] = temp ; n++ ; } //fermeture du fichier texte fclose(FicTxt); }
ca m'affiche bien ce qu'il y a dans le fichier texte puis 2 ligne en dessous d'autre caractères... mon expression du while n'est-elle pas bonne? :roll:Code:
1
2
3
4
5
6 while(Recuperation[i]!=NULL) { printf("%c",Recuperation[i]); i++; }
Edit:
j'ai un ptit warning d'ailleurs sur mon while :
Citation:
warning C4047: '!=' : 'int ' differs in levels of indirection from 'void *'