Hey guys i need help with my program. What I need to do is to open to inout files. one containing the accout numbers with there names and balance. the second is the transactin history with accout num ie 123 d45.67 d 56.78 w 78.99. My problem is that i get the files to open and the first read into an array of structs but i dont really now how to read the d and w. I was fooling with peek but dosnt work. i know my code might not look the best im still new at this.
int fillArrayT( PersonAcct customerArray[7], ifstream& inFileT)
{
int i=0;
int j = 0;
double tempdeposit = 0;
double tempwithdrawl = 0;
char ch;
int temp_acct_num;
inFileT >> temp_acct_num;
while ( !inFileT.eof())
{
/* cout << " tempdeposit" << tempdeposit << endl; // testing purpose
cout <<" temp_acct_num" << temp_acct_num << endl;// testing purpose
cout << " costumer deposit: " << customerArray[i].deposit <<" costumer withdrawl : " << customerArray[i].withdrawl << endl;// testing purpose
i++; // testing purpose */
for ( j = 0 ; j<6; j++)
{
if (temp_acct_num == customerArray[j].acct_num)
{
do
{
ch = inFileT.peek();
if (ch == 'd' || ch == 'D')
{
customerArray[j].deposit = 0;
inFileT >> tempdeposit ;
customerArray[j].deposit += tempdeposit;
}
else if ( ch =='w' || ch == 'W')
{
customerArray[j].withdrawl = 0;
inFileT >> tempwithdrawl;
customerArray[j].withdrawl -= tempwithdrawl;
}
}while(ch== 'd' || ch == 'w');
break;
}
}
}
return i;
}