help for ifstream and getline

Page 1 of 1

1 Replies - 270 Views - Last Post: 29 July 2014 - 01:21 PM Rate Topic: -----

#1 a01093  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 29-July 14

help for ifstream and getline

Posted 29 July 2014 - 01:10 PM

I don't know what is the problems and how to debug them.
Can anyone help me??
Thanks!!

file.txt:(just show few lines)
Product ID Name Type Price
UK24960 Cookies Food 131.45
JP28911 Roasted Duck Food 231.64
JP15519 Garden Biscuit Food 45.96
FR22679 Clark Leather Shoes Shoe 2606.8
AU12004 Bed Furniture 377.19
FR13873 DOUBLE BED Furniture 644.82
FR30360 2-seat Sofa Furniture 988.43

sample output:
Product ID Name Type Price
----------------------------------------------------------------------
AU07439 4-seat Sofa Furniture 5579.69
AU11644 Salomon X2 Pro Shoe 1342.33
AU12004 Single Bed Furniture 377.19
AU12034 Correction Pen Stationary 14.39
CN01001 Pen Stationary 23.82



void loadFile(string filename){ << error C2562: 'loadFile' : 'void' function returning a value
char id[20];
char name[40];
char type[20];
double price[20];

ifstream file(filename, ios::in); << error C2065: 'file' : undeclared identifier
cout << "Loading the product list file..." << endl;
if(file.is_open()){ << error C2228: left of '.is_open' must have class/struct/union
<< 1> type is ''unknown-type''
cout << "File is opened." << endl;
while(file.eof){ << error C2228: left of '.eof' must have class/struct/union
<< 1> type is ''unknown-type''
<< fatal error C1903: unable to recover from previous error(s); stopping compilation
file.getline(id, 50, '\t');
file.getline(name, 50, '\t');
file.getline(type, 50, '\t');
file.getline(price, 50, '\t');
cout << endl;
}
main_menu();
}
else{
cout << "Failed to open file." << endl;
return 1;
}
}


Is This A Good Question/Topic? 0
  • +

Replies To: help for ifstream and getline

#2 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5407
  • View blog
  • Posts: 27,410
  • Joined: 10-May 07

Re: help for ifstream and getline

Posted 29 July 2014 - 01:21 PM

** This is a duplicate topic **
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1