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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char ** lecture_fichier(FILE *,char *);
char ** ecriture_fichier(FILE *,char *);
void afficher(char **);
int main(void)
{
char tableau[20];
FILE *f1;
FILE *f3;
char **matrice_lecture;
char **matrice_ecriture;
f1=fopen("f1.txt","r");
if(f1==0){printf("Il n'y a pas de fichier f1");}
matrice_lecture=lecture_fichier(f1,tableau);
fclose(f1);
f3=fopen("f3.txt","a");
matrice_ecriture=ecriture_fichier(f3,tableau);
fclose(f3);
afficher(matrice_ecriture);
printf("\n\n");
system("pause");
}
char ** lecture_fichier(FILE *f,char *t)
{
static char* p[6];
int i;
for(i=0;i<6;i++)
{
p[i]=(char*)malloc(24);
}
i=0;
while(fgets(t,50,f)!=0)
{
strcpy(p[i],t);
i++;
}
return(p);
}
void afficher(char **m)
{
int i=0;
while(i<6)
{
printf("%s\n",m[i]);
i++;
}
}
char ** ecriture_fichier(FILE *f,char *t)
{
static char* p[6];
int i=0;
while(fputs(t,f)!=0)
{
strcpy(p[i],t);
i++;
}
return(p);
} |
Partager