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
|
FILE *ptfic;
int compteur;
char lire[250],Matable[500][250];
compteur=0;
if((ptfic=fopen("lefichier.txt","r"))!=NULL)
{
while (fgets (lire,210,ptfic) != NULL)
{
strcpy (Matable[compteur],lire);
compteur++;
}
fclose(ptfic);
}
Et pour ecrire
in a;
if((ptfic=fopen("lefichier.txt","w"))!=NULL) fclose(ptfic);
if((ptfic=fopen("lefichier.txt","a"))!=NULL)
{
for (a=0;a<compteur;a++)
{
Matable[a][208]=']';
Matable[a][209]='\0';
fprintf(ptfic,"%s\n",mondata[a]);
}
fclose(ptfic);
} |
Partager