Hi, I'm trying to send an array of data to a .txt file, and after a couple days am just rewriting code I wrote days ago.
I have an array of ints that I want to send to file in three columns
outputFile.open("sorted.txt");
for(int i = 0; i < size; i++)
{
if(i % 3 == 0)
{
outputFile << " Pos# " <<i <<" : " << id[i] << " " << setprecision(4) << showpoint << ave[i] << " :" << endl;
}
else
{
outputFile << " Pos# " <<i <<" : " << id[i] << " " << setprecision(4) << showpoint << ave[i] << " :";
}
}
outputFile.close();
I know why this is happeneing I just can't seem to think of a way to get three coloumns to print, I always run into trouble with the beginning few because 0 mod 3 is 0. I have the feeling I'm barking up the wrong tree.
This output is the closest I've gotten:
Pos# 0 : 9002 98.57 :
Pos# 1 : 1012 97.00 : Pos# 2 : 3199 97.00 : Pos# 3 : 9518 97.00 :
Pos# 4 : 1222 97.00 : Pos# 5 : 8928 97.00 : Pos# 6 : 4751 97.00 :
Pos# 7 : 4770 97.00 : Pos# 8 : 3939 97.00 : Pos# 9 : 3333 97.00 :
Pos# 10 : 8280 97.00 : Pos# 11 : 3434 97.00 : Pos# 12 : 1422 97.00 :
Pos# 13 : 2000 93.57 : Pos# 14 : 1919 93.43 : Pos# 15 : 6621 92.14 :
Pos# 16 : 5123 90.29 : Pos# 17 : 3993 90.29 : Pos# 18 : 9393 90.14 :
Pos# 19 : 4012 87.57 : Pos# 20 : 7655 86.29 : Pos# 21 : 6037 86.00 :
Pos# 22 : 7714 85.00 : Pos# 23 : 7880 84.71 : Pos# 24 : 9191 83.29 :
Pos# 25 : 5677 82.71 : Pos# 26 : 2012 81.57 : Pos# 27 : 8480 80.14 :
Pos# 28 : 9088 79.86 : Pos# 29 : 1412 77.43 : Pos# 30 : 3228 77.29 :
Pos# 31 : 5325 77.29 : Pos# 32 : 7788 76.57 : Pos# 33 : 1219 76.00 :
Pos# 34 : 1010 75.86 : Pos# 35 : 6658 74.57 : Pos# 36 : 9999 64.43 :
Pos# 37 : 6786 58.43 : Pos# 38 : 6547 56.86 : Pos# 39 : 1234 32.29 :
Pos# 40 : 3993 10.00 :