I wrote a simple routine to read and load values from my currency exchange rates.csv file, but it appears to keep reading the first record. Because of this, my check for EOF never gets satisfied. What is the secret to advancing to the next record and read the rest of the file? I am including my code for your review.
Code Tags Added by Kermi3Code: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 */ fstream infile; /* Define/create object type to be used for accessing the contents of the file. */ main() { infile.open( "currency exchange rates.csv", ios::in ); while( !infile.eof() ) { for (Row = 0; Row < 24; Row++) { for (Column = 0; Column < 24; Column++) { infile >> Curr_Conv_Factor; Currency_Conv[Row][Column] = Curr_Conv_Factor; printf("\n Currency Conversion amount in %i, %i is", Row, Column); printf("%f", Currency_Conv[Row][Column]); infile >> Curr_Conv_Factor; } } }



LinkBack URL
About LinkBacks


