i am having a problem with a function i am writing that takes in a txt file and stores the data in 3 arrays. The data file is always rows containing three numbers such as
1 2 3
2 3 4
5 6 7
8 9 10
with each column being specific to an array. The problem i am having is that when the file is being assigned to the arrays in a for loop it always skips the 1,5,9, etc number. This causes damage to the output because it offsets the array assignments so they dont have the right numbers in them. My code is posted below and im not sure if it is a problem with the loop i wrote, or if it is a problem with the way the file is being read. I just need someone to push me in the right direction on this because i have been working on it for hours.
Thanks
int ReadFile(char fname[], double prin[], double rate[], double pay[])
{
int c, d;
cout<<"\nEnter the name of the data file: ";
cin>>fname;
ifstream inFile(fname);
for(c=0;c<=100;c++)
{
if(!(inFile>>fname))
{
break;
}
inFile>>prin[c]>>rate[c]>>pay[c];
}
inFile.close();
for(d=0;d<(c+1);d++)
{
cout<<"Record "<<(d+1)<<": "<<prin[d]<<" "<<rate[d]<<" "<<pay[d]<<"\n";
}
return (d);
}