Re: macro problem

Nick van Eijndhoven (Nick@phys.uu.nl)
Thu, 03 Dec 1998 14:22:55 +0100


Canguo Li wrote:
>
> On Thu, 3 Dec 1998, Dr. Roberto Barbera wrote:
>
> > Hi experts,
> >
> > I've modified the tutorial macro basic.C to read an ASCII file
> > containing several lines of 12 elements each (3 integers and 9 reals).
> > Here is the macro i'm using:
>
> > ncols = fscanf(detfile,"%i %i %i %f %f %f %f %f %f %f %f
> > %f",
> > &ilayer,&iladder,&idet,&f1,&f2,&f3,&f4,&f5,&f6,&f7,&f8,&f9);
>
> > and this is what i get when i run the macro inside ROOT:
> >
> > root [0] .x readet.C
> > Reading Detector Map from file...
> > Limitation: fscanf only takes upto 12 arguments
>
> I tried your example. If you reduce items to read from 12 to 10, then
> it works. fscanf() obviously takes the file descriptor and format as 2
> arguments.
>
> The question how to read in more than 10 items remains answered.
>
> regards
>
> --Canguo

Dear Roberto, Canguo and others,
Instead of fscanf() I always use the 'standard' C++ ifstream etc...
This never gave me problems so far.

-- 

Cheers,

_/_/ _/ _/ _/_/_/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/_/_/_/ _/ _/

*----------------------------------------------------------------------* Dr. Nick van Eijndhoven Department of Subatomic Physics email : nick@phys.uu.nl Utrecht University / NIKHEF tel. +31-30-2532331 (direct) P.O. Box 80.000 tel. +31-30-2531492 (secr.) NL-3508 TA Utrecht fax. +31-30-2518689 The Netherlands WWW : http://www.phys.uu.nl/~nick Office : Ornstein lab. 172 ---------------------------------------------------------------------- tel. +41-22-7679751 (direct) CERN PPE Division / ALICE exp. tel. +41-22-7675857 (secr.) CH-1211 Geneva 23 fax. +41-22-7679480 Switzerland CERN beep : 13+7294 Office : B 160 1-012 *----------------------------------------------------------------------*