I send out multiple types of variables (i.e. 2 char arrays, 1 int, 1 double, and two more char arrays). But when I read then back at the beginning of the program (building a LLL) I get multiple declarations of the same variables and then when I display the LLL it stops at the beginning as if waiting for input.
Console Result:
Name: a b
Acct Num: 1801640999
Balance: $0
Name: a b
Acct Num: 1801640999
Balance: $0
Name: c d
Acct Num: 1801674613
Balance: $0
Name: a b
Acct Num: 1801640999
Balance: $0
Name: kill
quit
This code reads in from the file:
ifstream fin ("AccountDatabase.dat");
while (fin && !fin.eof())
{
Node * temp = new Node;
char first [100];
char last [100];
int acctnumber;
double balance;
//char notes [100];
char created [80];
char modified [80];
fin >> first >> last >> acctnumber >> balance >> created >> modified;
}
This code sends it to the file:
ofstream fout;
fout.open("AccountDatabase.dat", ios::app);
Node * temp = head;
while (temp && !fout.eof()) {
fout << temp->first << " ";
fout << temp->last << " ";
fout << temp->accountNumber << " ";
fout << temp->balance << " ";
fout << temp->dateCreated << " ";
fout << temp->dateModified << endl;
temp = temp->next;
} // while
fout.close();
A look at the file "AccountDatabase.dat" is:
a b 1801640999 0 08/18/2010 08/18/2010
c d 1801674613 0 08/18/2010 08/18/2010
a b 1801640999 0 08/18/2010 08/18/2010
Any help would be great! I have been looking for a long time on Google and on the forums!