I am trying to read this data from a text file into my 2d array. There are many more columns, but the data below is just a small portion. I am able to read the first digit "5.1" but the majority of what is being printed out are some 0's follows by garbage. What am I doing wrong with my code?
Portion of the text file data:
5.1,3.5,1.4,0.2
4.7,3.2,1.3,0.2
4.6,3.1,1.5,0.2
5.0,3.6,1.4,0.2
5.4,3.9,1.7,0.4
if (!fin)
{
cout << "File not found! " << endl;
}
const int SIZE = 147;
string data[SIZE];
double data_set[SIZE][4];
for (int i = 0; i < SIZE; i++)
{
for (int j = 0; j < 4; j++)
fin >> data_set[i][j];
}
for (int i = 0; i < SIZE; i++)
{
for (int j = 0; j < 4; j++)
cout << data_set[i][j] << " ";
cout << endl;
}