Your problem is that you are using the extraction operator to read into a numeric variable, but your input contains non-numeric characters. Your program is not reading the same value over and over, it reads it once and encounters the comma at which point it stops reading (due to error) and each time through the loop your variable doesn't change.
Here's a simple (albeit not too elegant) fix that will get you around your woes:
Code:
#include <iostream>
#include <fstream>
#include <string>
int main() {
float Curr_Conv_Factor; /* Individual currency conversion factor read from
file to be used to fill the array */
float Currency_Conv[24][24]; /* Array containg currency conversion factors */
int Row; /* Row position in currency conversion array */
int Column; /* Column poistion in currency conversion array */
std::fstream infile; /* Define/create object type to be used for accessing
the contents of the file. */
infile.open( "in.csv", std::ios_base::in );
std::string field;
while( infile.good() ) {
// check if the file is still good in your inner loops too
for (Row = 0; Row < 24 && infile.good(); Row++) {
for (Column = 0; Column < 24 && infile.good(); Column++) {
if (Column == (24 - 1))
std::getline(infile, field);// last field on a line isn't comma-delimited
else
std::getline(infile, field, ',');// but the rest are
Curr_Conv_Factor = std::atof(field.c_str());// convert string to floating point numeric
Currency_Conv[Row][Column] = Curr_Conv_Factor;
std::printf("\n Currency Conversion amount in %i, %i is ", Row, Column);
std::printf("%f", Currency_Conv[Row][Column]);
}
}
}
return 0;
}