To print to a text file

Dear rooters.
Tell me please ,how can i print(firstly open it)to a text (data) file every x and y(wich had filled histograms) ?
Thanks.

see example below. However, note that you should refrain posting these very basic questions to this forum. I strongly suggest that you follow a beginner course on C++
and practice as much as possible the various tutorials to try understand what they are doing.

{ TH1F *h = new TH1F("h","test",100,-3,3); FILE *fp = fopen("oma.log","w"); TRandom r(0); for (int i=0;i<100;i++) { double x = r.Gaus(0.5,1.); fprintf(fp,"i=%4d, x=%g\n",i,x); h->Fill(x); } fclose(fp); }

Rene

Thank you mr Rene,for you suggestions and helps.
I wil do as you said.