I am using cern's data analysis framework, ROOT. What I am trying to do is export in an ascii file the contents of a TH1F histogram. My sample code is the following
#include "TH1.h"
#include "TH1F.h"
#include <iostream>
#include <fstream>
using namespace std;
void histo2ascii(TH1* hist){
ofstream myfile;
myfile.open ("movie_small.txt");
for (int i=1; i<=hist->GetNbinsX(); i++){
if(hist->GetBinCenter(i)>5.e-3 && hist->GetBinCenter(i)<7.e-3){
//myfile << (float) hist->GetBinCenter(i) << "\t" << hist->GetBinContent(i) << endl;
fprintf(myfile, "%.17g \t %d", hist->GetBinCenter(i), (int) hist->GetBinContent(i));
}
}
myfile.close();
}
The problem is that, when I compile it (OK, through cint, using .L code.C++ :/) I get the following error
invalid conversion from ‘void*’ to ‘FILE*’
at fprintf
line.
Any idea on why this might be happening?