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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
| #include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *pf1,*pf2,*pf3;
FILE * pf;
int i=0,j;
char nom[17],mot[17]="livre",c,x,k,l[2];
//printf("donner le nombre de chapitres n ");
//scanf(" %d ",&n);
printf("donner le numero du livre j ");
scanf(" %d ",&j);
//printf("donner le mot clé");
//scanf(" %s ",mot);
strcpy(nom,"livre");
k=dtoa(j);
strcpy(l,k);
strcat(l,"\0");
strcat(nom,l);
strcat(nom,"chap\0");
/*ouvrir le fichier pdf*/
pf1=fopen("pdf.txt","rt");
if (pf1=NULL) return 0;
/*ouvrir le fichier exemple html1*/
pf2=fopen("expl1.txt","rt");
if (pf2=NULL) return 0;
/*ouvrir le fichier exemple html2*/
pf3=fopen("expl2.txt","rt");
if (pf3=NULL) return 0;
pf=fopen(nom,"wt");
while(1)
{ i++;
/*ouvrir le fichier livreJchapI.txt*/
k=dtoa(i);
strcpy(l,k);
strcat(l,"\0");
strcat(nom,l);
strcat(nom,".html\0");
pf=fopen(nom,"wt");
if (pf=NULL) return 0;
/*copier expl1.html dans le fichier*/
c=getc(pf2);
while (c!=EOF)
{
putc(c,pf);
c=getc(pf2);
}
/*copier le chapitre à partir de pdf.txt*/
x=getc(pf1);
while (x!=EOF && x!="*")
{
putc(x,pf);
getc(pf1);
}
/*copier expl1.html dans le fichier*/
c=getc(pf3);
while (c!=EOF)
{
putc(c,pf);
c=getc(pf3);
}
/*PASSER AU CHAPITRE SUIVANT*/
fclose(pf);
/*MAJ de la variable nom*/
strcpy(nom,"\0");
strcpy(nom,"livre");
k=dtoa(j);
strcpy(l,k);
strcat(l,"\0");
strcat(nom,l);
strcat(nom,"chap\0");
if(x==EOF) break;
}
fclose(pf1);
fclose(pf2);
fclose(pf3);
return 0;
} |
Partager