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
|
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
/* data file comp.dat
Exemple de 2 lignes (en realité des fichiers assez gros):
T_1 qcxlodqelim : 12 41 35 Geriatric Medicine : Rehabilitation Medicine : Old Age Psychiatry
T_2 jmwdkbutnsk : 0 19 52 Immunology : Infectious Diseases : Trauma & Orthopaedic Surgery : Psychotherapy
*/
char tmp[1000] ;
FILE *reading, *writting, *lecture ;
ssize_t read;
char * line = NULL;
size_t len = 0;
int tempo;
int main(void)
{
FILE *reading ;
reading=fopen("comp.dat","rt");
while(read=getline(&line,&len,reading)!=-1)
{
/*printf("%zu\n",read);
printf("%s",line);*/
writting=fopen("temporaire","wt");
fprintf(writting,"%s\n",line);
fclose(writting);
lecture=fopen("temporaire","rt");
fscanf(lecture,"%s",tmp);
fscanf(lecture,"%[^:]%*c",tmp);
printf("task title : %s ",tmp);
fscanf(lecture,"%d",&tempo);
printf("<%d>",tempo);
fscanf(lecture,"%d",&tempo);
printf("<%d>",tempo);
fscanf(lecture,"%d",&tempo);
printf("<%d>",tempo);
while( fscanf(lecture,"%[^:]%*c",tmp) !=EOF )
{
printf("|%s",tmp);
}
printf("\n");
fclose(lecture);
}
fclose(reading);
} |
Partager