Inserting data in ROOT(data conversion problem)

From: Ivan Koji Koga <ivankoga_at_yahoo.com.br>
Date: Tue, 08 Mar 2005 07:44:52 -0300


Hello all,
I have been using ROOT to insert some values and they appear like all have the same value. I think that it's some error on the data conversion when i try to convert string to int, but i don't know what i'm doing wrong. The 104-10-06-0084.icmp is a file that contain some network delay values like:

0 59
60 58
120 58
180 57
240 loss
300 61
360 58
420 loss
480 58
540 57

On the left we have timestamp values and on the right delay values that can be "loss" or numeric int.
Can anyone tell me what is wrong in the code and how to correct it?

{

struct tipo_atrasos {

    Int_t timestamp;
    Int_t atraso;
};

tipo_atrasos vatraso;
char line[80];
char temp[80];
char temp1[80]="loss";
int tempint;
//open file

FILE *at = fopen("/104-10-06-0084.icmp", "r");

// new TFile

TFile *f = new TFile("dadosAMP.root", "RECREATE");

// new TTree

TTree *arvore = new TTree("arvore", "dados do amp");

//new Brach

arvore->Branch("galhoAMP", &vatraso.timestamp, "timestamp/I:atraso");

//fill the values

while(fgets(&line,80,at))
{
sscanf(&line[0],"%d%s", &vatraso.timestamp, &temp);

if(strcmp(temp,temp1)==0){
//if it's loss then delay = 9999

&vatraso.atraso=9999;
printf("loss \n");

}
else {
//if not loss receive the numeric value

tempint=atoi(temp);
&vatraso.atraso = tempint;
}
arvore->Fill();
}
//Print and close;

arvore->Print();
fclose(at);
f->Write();
} Received on Tue Mar 08 2005 - 11:48:28 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:05 MET