Writing Truncation error and maxD

Hello,
How to write truncation error and maxDim for last sweep in c++. Since I am able to see truncation error on screen after completion of code. But I want to write it in a file.

Thanks,
Vrushali.