I am filling a multidimensional array up from a file and inside the loop when i print the value of what i want it is correct but when i cout outside of the loop it's a different value
// this is the code
// read from file and fill arrays
float data[9][2]; // array reads angle, w(angle) errw(angle)
int x = 0;
float a,b,c,d,e,f;
while ( dat >> a >> b >> c){
data[x][0] = a;
data[x][1] = b;
data[x][2] = c;
cout << data[x][2] << endl;
x++;
}
dat.close();
cout << data[0][2] << endl;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// this is the text to screen
Input filename where the raw data exist-->dat.dat
0.023009
0.017027
0.013554
0.015127
0.010707
0.014515
0.01358
0.016766
0.022473
0.077017
37.5 // this is the number that is funny that i print out after
Input filename where the data table exist-->
data[9][2] means you can use the indexes 0 and 1 (=2 values) only and not the index 2
data[9][2] means you can read 9 lines only. Just count how many lines you have in your file