Number in filename -> variable

hi there!

this seems a very simple question, yet i wasn’t able to solve the problem till now!
so i have a bunch of files in a directory all named “JPsi_BW_xxxxx.dat.root” (xxxxx are numbers of format ‘4.06650’ and so on) and what i want to do it loop over all files in the dir and make ROOT understand that this number in the filename is a variable (called “moms”) unique to each file that is stored and later on used for further computations.

so i’ve tried all kinds of sprintf-sscanf-fgets combinations but the assignment of the number as a variable just isn’t working!

the error message i get is

moms 0x9add20
Error: @ Illegal operator for pointer 2 ana_JPsi.C:83:
Error: @ Illegal operator for pointer 2 ana_JPsi.C:83:

by the way, there’s nothing fishy going on in line 83, that should be a straight-forward calculation using moms, but i assume that since moms is something weird, ROOT can’t process it.
anybody any ideas?

cheers,
Kati

the scanning version for now is

sscanf(entry,"%s_%s_%f.%s.%s",&str1,&str2,&moms,&str3,&str4);

and that also gives a seg violation when exiting ROOT…

[quote=“kati.nikolics”]the scanning version for now is

sscanf(entry,"%s_%s_%f.%s.%s",&str1,&str2,&moms,&str3,&str4);

and that also gives a seg violation when exiting ROOT…[/quote]

It depends on what str1…4 are defined to be, but you probably don’t want to be passing the address of them (i.e., try dropping the '&'s).

Cheers,
Charles