Writing parameters to text file

I’m fitting a quadratic to some data, so I’m fitting two parameters. These parameters are then written in the standard TPavestats box but I would like to write them to a text file.

How do I open a text file then write these parameters to it and save it?
Any help would be much appreciated.

Cheers,
Chris.

Hi Chris,
here’s a web page that gives you some examples on C++ and regular file I/O: http://www.cplusplus.com/doc/tutorial/tut6-1.html
The documentation for TH1 at http://root.cern.ch/root/html/TH1 tells you how to access the fit parameters:

Associated functions
====================
One or more object (typically a TF1*) can be added to the list
of functions (fFunctions) associated to each histogram.
When TH1::Fit is invoked, the fitted function is added to this list.
Given an histogram h, one can retrieve an associated function
with: TF1 *myfunc = h->GetFunction(“myfunc”);

  Access to the fit results
  =========================
 If the histogram is made persistent, the list of
 associated functions is also persistent. Given a pointer (see above)
 to an associated function myfunc, one can retrieve the function/fit
 parameters with calls such as:
   Double_t chi2 = myfunc->GetChisquare();
   Double_t par0 = myfunc->GetParameter(0); //value of 1st parameter
   Double_t err0 = myfunc->GetParError(0);  //error on first parameter

Axel.

Cheers, got it running perfectly.