Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File

Status
Not open for further replies.

mayu03

Programmer
Joined
Oct 3, 2003
Messages
91
Location
US
I was able to open the file, but I have trouble getting data.
My file looks like this:
account amount pendamount
123456 231.00 78.00
I need to read the data into variable account and amount then use get() again with no argument in order to through away the new line character at the end of the line .
Thanks
 
something like this:
float x;
while(yourFile)
{
yourFile>>x;
cout<< x<< endl;
}

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Here is my code:
while(!inpf.eof())
{char account(16);
double gallons;
inpf.get(account);
cout << account << endl;
}
What is incorrect ? i am not able to pull account name into account?
 
maybe you mean
Code:
char account[16];
instead of
char account(16);?

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
That is how I modified my code:
do{
char name[15];
inpf.get(name,16);
}while(!inpf.eof())
I am not reading only the first last and not reading the rest of the lines.even when I read the first line I read all line instead of reading only first 15-16 char.
 
1. replace 15 with 16 and viceversa
2. I think you should use read instead of get

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top