sprintf(hadcname,"adc_channel_%d",iloop);
sprintf(htdcname,"tdc_channel_%d",iloop);
hadc[iloop] = new TH1I(hadcname,"",4096,0,4095);
htdc[iloop] = new TH1I(htdcname,"",4096,0,4095);
I did this. (In fact I tried this before) but this still gives me the following error
daq_root.cpp:94: error: expected unqualified-id before ‘for’
daq_root.cpp:94: error: expected constructor, destructor, or type conversion before ‘<’ token
daq_root.cpp:94: error: expected constructor, destructor, or type conversion before ‘++’ token
In C++ you can only have declaration outside of a function. So you must move your for loop (around line 94) inside a function (the main function is likely the best place).