Please support our C++ advertiser: Programming Forums
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,873
Reputation:
Rep Power: 14
Solved Threads: 344
Hi
my name is Peter and I'm looking for somebody who can help me to understand how to read from external file without "destroing" existing inforamtion inside.
whole staff is based on book example which i'm trying to extend.
I have a programm which is working with database of 3 three accounts.
There is no problem to do operation on it(Deposit, Withdraw) and update data file. However if I insert there on start extra line which state how many accounts are there everything gets funy
data file
3 accounts
123 100.0
840 123.5
666 823.9
first number is account number second is current balance
and here is part of code which is looking for information on first line "3"
ifstream accfile;
accfile.open("accounts.dat");
int na; //number of accounts
accfile >> accs[1].accno;
cout << accfile << endl;
getline ( accfile, na);
cout <<"Number of accounts = " << na << endl;
give me error : no matching function for call to `getline (ifstream &, int &)'
if I declare na as string
cout brings "Numbers of accounts = accounts"
this does erease first line
my name is Peter and I'm looking for somebody who can help me to understand how to read from external file without "destroing" existing inforamtion inside.
whole staff is based on book example which i'm trying to extend.
I have a programm which is working with database of 3 three accounts.
There is no problem to do operation on it(Deposit, Withdraw) and update data file. However if I insert there on start extra line which state how many accounts are there everything gets funy
data file
3 accounts
123 100.0
840 123.5
666 823.9
first number is account number second is current balance
and here is part of code which is looking for information on first line "3"
ifstream accfile;
accfile.open("accounts.dat");
int na; //number of accounts
accfile >> accs[1].accno;
cout << accfile << endl;
getline ( accfile, na);
cout <<"Number of accounts = " << na << endl;
give me error : no matching function for call to `getline (ifstream &, int &)'
if I declare na as string
cout brings "Numbers of accounts = accounts"
this does erease first line
Similar Threads
Other Threads in the C++ Forum
- Writing data to a file. (C++)
- help me to read my data file:(( (C)
- Please help with data file and array (C++)
- Help creating a data file (C)
- input data from a file into an Array (C)
- data file help (C)
Other Threads in the C++ Forum
- Previous Thread: Question:: reading from an input stream.
- Next Thread: queue
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)







Threaded Mode