float a [6][13]; // Begins the array to read the values from the hardwood file
int i;
for (i=0; i<6; i++)
{
for (int j=0; j<13; j++)
hard>>a[i][j];
}
The above might work if there were no commas in-between every number , however, your file (at least the one posted above) has all of the values separated by a comma..I believe this is messing up your ability to read in the correct values..(also not sure why you declare int i;
)
Try code below as an alternative..
float a [6][13]; // Begins the array to read the values from the hardwood file
float value;
char comma;
for (i=0; i<6; i++)
{
for (int j=0; j<13; j++){
hard>>std::ws>>value; //get value from file ignoring whitespace
a[i][j] = value;
hard>>std::ws>>comma; //ignore commas and whitespace
}
}
The second part of your question has the same problems really...you arn't taking into account the commas... You have like before..
float a [12][13]; //begins the array so the input file can be read
int i, j;
for (i=0; i<12; i++)
{
for (int j=0; j<13; j++)
soft>>a[i][j];
}
You should have...
float a [12][13]; // Begins the array to read the values from the hardwood file
float value;
char comma;
for (i=0; i<12; i++)
{
for (int j=0; j<13; j++){
soft>>std::ws>>value; //get value from file ignoring whitespace
a[i][j] = value;
if(j != 12){ //dont ignore the comma for last entry on line bc no comma there
soft>>std::ws>>comma; //ignore commas and whitespace
}
}
}