file.txt
123.56
89.78
8.89
468.98
567.90
5.78
178908.90
12.56
6789.90
12.56
16.780
0.00
I've parsed the numbers into an array called float A[150] = {0}. So, A looks like:
A[0] = 123.56
A[1] = 89.78
....
....
A[10] = 16.780
A[11] = 0.00
A[12] = 0
A[13] = 0
...
...
Then, I have a sorting Algorithm
Sort(A, i) // where i is the number of elements (12)
Now A[] looks like
A[0] = 0
A[1] = 5.78
...
...
A[10] = 6789.90
A[11] = 178908.90
Then, I write it to a file called "Final.txt"
std::ofstream File (Name);
if (File.is_open())
{
for (j = 0; j < i; j++)
{
File << A[j] << std::endl;
}
}
The file output "Final.txt" looks like:
0
5.78
8.89
12.56
12.56
16.78
89.78
123.56
468.98
567.9
6789.9
178909 // Why it is NOT CORRECT !!!!!!!
The problem with A[11] after the sorting, why is it not correct in "Final.txt", even though it is correct when I debug it in the A[11] ?