+ 1

ofstream in c++

Iā€™ve made a program to calculate averages using a while and for loop and then I wanted to take each of those averages and insert them into a .txt file. Every time I do this it only ends up posting the last average. Can someone help?

21st Sep 2018, 1:43 AM
Seth
4 Answers
+ 4
I see that you have an infile, which means that the values you want to calculate your average based on is stored in an external file. You may need to provide an example of the input file. The structure of the file is important for us to determine how to read it properly. If that's not possible, I assume your file stores values in the format: 56 78 23 ... vertically?
21st Sep 2018, 3:38 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
https://code.sololearn.com/cUmcHagKB826/#cpp this codes counts average of all values in a single input file. I didn't get how do you want to cont averages(from different files, single one etc.), so did this one.
21st Sep 2018, 8:22 AM
MarJan
MarJan - avatar
0
i left some stuff out but you get the idea
21st Sep 2018, 1:52 AM
Seth