Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my output go to cout rather than to file?

I am doing some scientific work on a system with a queue. The cout gets output to a log file with name specified with command line options when submitting to the queue. However, I also want a separate output to a file, which I implement like this:

ofstream vout("potential.txt"); ...
vout<<printf("%.3f %.5f\n",Rf*BohrToA,eval(0)*hatocm);

However it gets mixed in with the output going to cout and I only get some cryptic repeating numbers in my potential.txt. Is this a buffer problem? Other instances of outputting to other files work... maybe I should move this one away from an area that is cout heavy?

like image 629
ntype Avatar asked Feb 25 '23 18:02

ntype


1 Answers

You are sending the value returned by printf in vout, not the string.

You should simply do:

vout << Rf*BohrToA << " " << eval(0)*hatocm << "\n";
like image 50
BenjaminB Avatar answered Mar 08 '23 12:03

BenjaminB