Making histogram from text file

Hello everyone.
I am trying to generate a histogram from my data file but the data files contains a lot colums and I want to read data one by one.

For example:
2 4 5
5 7 0
6 1

And I want to read data and fill the histogram start 2,4,5,5,7 and so on…

I am trying this:

void Plotting(){

TH1F *h = new TH1F(“h”, “histogram”,1000,5.,9.);
ifstream inp; double x;

inp.open(“data.dat”);
for (int i=1; i<=1000; i++) {
inp >> x;
h->SetBinContent(i,x);
}
h->Draw();
}

I am afraid that I am only reading the first column. Can someone help me how I can read all values one by one?

It looks like your “data file” contains variable length vectors, so you’d better contact the “author” of this file, who should be able to provide you with an appropriate “parser”.

I am actually generating the data files using a monte carlo program.

So, talk to people familiar with this “monte carlo program” (e.g., your colleagues and/or supervisor).

Okay. Thank you, I will do so.