You should just convert your script to C++
- use
const char *
, not fixed-sizechar
arrays - use
std::vector
, not fixed-sizedouble
arrays - and most crucially, fix the
ifstream
reading loop.
Your issue was that you had 50 elements but only read 49 lines. That meant one bogus number, and that meant the fit didn’t converge. The attached version fit.C (1.8 KB) fixes that! It also makes the code simpler, more readable, and more stable: less magic buffer-size number etc. So there’s plenty of motivation to try out some more advanced C++
Cheers, Axel.