Plotting a txt file

Every time I tried to plot a histogram with a data it shows error in fstream, not sure if the error is on root or the C program.
rror: no matching constructor for initialization of ‘std::__1::fstream’ (aka

’basic_fstream’)

TH1F *hist = new TH1F("hist","Histogram",100,0,100);
fstream file;
file.open("C07.txt", ios::in);
double value;
while(1)
    {
        file>>value;
        hist -> Fill(value);
        if (file.eof())break;

    }
    hist ->GetXaxis() ->SetTitle("data");
    hist ->GetYaxis()->SetTitle("Percentage");    
    

    TCanvas*c1 = new TCanvas();
    hist ->Draw();
    

}



Try with

ifstream file;
file.open("C07.txt");
1 Like