When I run this program I can only access the first row of data. Can any one help so that I can access all the lines? I am trying to store numbers into a 2-dimensional array.
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
int main ()
{
ifstream inData;
float numbers[25][10];
int rows=0,cols;
inData.open("data.txt");
while (inData){
for (rows=0; rows<=7; rows++){
for (cols=0; cols<=7; cols++)
{
inData >> numbers[rows][cols];
cout<<fixed<<showpoint<<setprecision(1)<<numbers[rows][cols]<<" ";
}
cout<<endl;
}
}
cout<<endl;
cout<<fixed<<showpoint<<setprecision(1)<<numbers[0][1];
return 0;
}