fscanf limitation

From: Christophe Suire (suire@in2p3.fr)
Date: Wed Dec 08 1999 - 18:25:53 MET


Hello,

I have the following error when I try  to use the macro "reading an
ascii file " ( look at the end of the mail ) with a large number of
arguments.
 
 Limitation: fscanf only takes upto 12 arguments
 FILE:/home/suire/Test_prod/data/./mynt.C LINE:34
 *** Interpreter error recovered ***
 
I understand well the error but I cannot reduce the number of rguments.
Any ideas how to do it.
 
  Thanks.


 
 Reading an ascii file and making an ntuple
 
 {
 //   example of macro to read data from an ascii file and
 //   create a root file with an histogram and an ntuple.
 
    gROOT->Reset();
 
    FILE *fp = fopen("/user/brun/root/basic.dat","r");
 
    Float_t x,y,z;
    Int_t ncols;
    Int_t nlines = 0;
    TFile *f = new TFile("basic.root","RECREATE");
    TH1F *h1 = new TH1F("h1","x distribution",100,-4,4);
    TNtuple *ntuple = new TNtuple("ntuple","data from ascii
 file","x:y:z");
 
    while (1) {
       ncols = fscanf(fp,"%f %f %f",&x, &y, &z);
       if (ncols < 0) break;
       if (nlines < 5) printf("x=%8f, y=%8f, z=%8f\n",x,y,z);
       h1->Fill(x);
       ntuple->Fill(x,y,z);
       nlines++;
    }
    printf(" found %d points\n",nlines);
 
    fclose(fp);
 
    f->Write();
 }

-------------------------------------------------
Christophe Suire                                   suire@in2p3.fr
Institut de Recherches Subatomiques   phone: +33(0)388106154
23,rue du Loess Bat20 BP28                fax:   +33(0)388106614
F-67037 Strasbourg cedex2
-------------------------------------------------

 

-------------------------------------------------
Christophe Suire                                   suire@in2p3.fr
Institut de Recherches Subatomiques   phone: +33(0)388106154 
23,rue du Loess Bat20 BP28                fax:   +33(0)388106614
F-67037 Strasbourg cedex2 
-------------------------------------------------



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:44 MET