Bonjour ,
Mes objectifs sont simple :
Se positionner à partir de la 3° ligne d'un fichier passé en paramètre
Récupérer 8 lignes à la fois de ce fichier
Les traiter dans un fichier temporaire
Supprimer ce fichier temporaire et recommencer l’opération .
Voila ce que j'ai écrit :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
#define bufSize 2000
void make_filter(char *file){
FILE *fp ;
fp=fopen(file,"r");
char buf[bufSize];
int count ;
int i ;
FILE *final ;
final=fopen("zoo.txt","a");
count=make_count(filename); // count the number of lines
while(fgets(buf,bufSize,fp)!=NULL){
    buf[strlen(buf)-1]='\0';
    if (strstr(buf,"<date>")!=NULL){
        if (strstr(buf,"<hour>")!=NULL){
            if (strstr(buf,"<machine>")!=NULL){
                if (strstr(buf,"<line>")!=NULL){
                    if (strstr(buf,"<message>")!=NULL){
                        if (strstr(buf,"</event>")){
                            fprintf(final, "%s\n",buf);
                        }
                    }
                }
            }
        }
    }
}
fclose(final);
fclose(fp);
}
Si quelqu'un pourrait m'aider , ça serait gentil.