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
| int main()
{
FILE* monFichier = NULL;
char *temp;
char** tab;
int i=0;
int j = 0;
int taille = 0;
tab = (char**)malloc(sizeof(char*));
monFichier = fopen("C:\\Users\\Julien\\Desktop\\test.txt","r");
if (monFichier != NULL)
{
while(!feof(monFichier))
{
temp = LireMot(monFichier);
taille = strlen(temp);
tab[i] = (char*)malloc(taille*sizeof(char)+1);
strcpy(tab[i],temp);
i++;
tab = (char**)realloc(tab, i*sizeof(char*));
}
}
else
printf("Impossible d'ouvrir le fichier");
for(j = 0; j< i; j++)
printf("%s", tab[j]);
system("pause");
} |