I have a table in a text file that looks like this:
FICO Cur_Bal
729 39030.46
770 16542.66
815 14093.92
668 37974.53
738 47587.13
my code tries to read the table into a 2D array and convert the numbers into floats.
string Borrowers[6][12];
int main ()
{
ifstream inFile ("test.txt");
for (int i = 0; i < 6; i++){
for (int j = 0; j < 3; j++){
inFile >> Borrowers[i][j];
}
}
cout<<Borrowers[1][0];
cout<<Borrowers[1][1].c_str();
//cout<<atof(Borrowers[1][0].c_str());
return 0;
}
for some reason, cout<<Borrowers[1][1] returns me 7 2 9 (with the extra spaces between the digits), and cout<<Borrowers[1][1].c_str(); returns me 0. what am I doing wrong here?
This almost looks like something a person would export from a speadsheet or database, with column descriptions. Why not export without headings and then do something like this