I have a loop
in every loop-step
I want to print namei and valuei into a txt file
the format is as below
between the name line and the value line there is a blank line
how to achieve this? Thanks!
Why not accumulate the data in two separate stringstreams and write them to the file after the loop ends?
Otherwise, try reading the file stream documentation. There is a way to manipulate the position of the stream. Before the first write, save the current stream position. You could use some simple math to seek to the correct position before each write. You'll have to remember how much data has been output on each line so that you can use this as an offset from the initial stream posisiton.