Hi Livia, You must use char* type instead of int. - int timestamp; + char timestamp[15]; ...... - sscanf(temp, "%d %s %s %d %g %d", - &id, &name1,&name2, &type, &measure, ×tamp); - printf("%d %s %s %d %g %d\n", id, name1,name2, type, measure, timestamp); + sscanf(temp, "%d %s %s %d %g %13s" + &id, &name1,&name2, &type, &measure, timestamp); + printf("%d %s %s %d %g %s\n", id, name1,name2, type, measure, timestamp); Best regards, Stanislav. On Wed, 25 Jun 2003, Livia FERRO wrote: > Hello, > > I'm a Summer Student and I've a problem with root. > I would like to read a data file like this: > > 25 ext probe 1 21.93 1052989373314 > 26 ext probe 1 19.95 1052989373362 > 27 ext probe 1 20.25 1052989373418 > 28 ext probe 1 20.40 1052989373465 > 29 ext probe 1 20.36 1052989373517 > 30 ext probe 1 19.99 1052989373620 > 31 ext probe 1 21.17 1052989373683 > > In order to do this, I have written a script: > > { > gROOT->Reset(); > > int id; > char name1[10]; > char name2[10]; > int type; > float measure; > int timestamp; > char temp[200]; > FILE *apre; > > apre = fopen("extprobe.dat","r"); > > while(fgets(temp, sizeof(temp), apre) !=NULL) { > > sscanf(temp, "%d %s %s %d %g %d", > &id, &name1,&name2, &type, &measure, ×tamp); > printf("%d %s %s %d %g %d\n", > id, name1,name2, type, measure, timestamp); > > } > > fclose(apre); > } > > > Alas, it doesn't work, because it can't manage to read the last number > of each line (it's too long). > Could you give any hint? > > Thank you very much. > > Livia Ferro > >
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET