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
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int i;
int lecture;
FILE *fichier;
char nm_fic[10];
char (*buffer)[500];
size_t taille=0;
scanf("%s",nm_fic);
fichier=fopen(nm_fic,"rb");
if (fichier!= NULL)
{
printf("OUverture fichier.\n");
buffer=malloc(500*sizeof(char));
if (buffer != NULL)
{
fscanf(fichier,"%s",buffer);
for (i=0; i<strlen(buffer); i++)
{
if (buffer[i])
++taille;
}
printf("Taille %d\n",taille);
}
else
{
printf("Echec allocation memoire\n");
}
}
free(buffer);
fclose(fichier);
system("pause");
return 0;
}
Merci de votre attention ;) , bonne soirée ! |
Partager