RSS Forums RSS
Please support our C++ advertiser: Programming Forums
Views: 6162 | Replies: 2 | Thread Tools  Display Modes
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,873
Reputation: peter_budo is just really nice peter_budo is just really nice peter_budo is just really nice peter_budo is just really nice peter_budo is just really nice 
Rep Power: 14
Solved Threads: 344
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Reading from external data file

  #1  
Dec 11th, 2004
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
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 9:08 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC