here is my attempt at loading a file:
dont laugh
Code:
if(action=="open"){
ifstream imput("outfile.txt"); for(int i=0;i<6;i++){
string tempName="";
float temppPrice=0,tempsPrice=0;
int tempQ=0;
imput >>tempName >> temppPrice >> tempsPrice>>tempQ;
sarray[i].setName(tempName); sarray[i].setpPrice(temppPrice);
sarray[i].setsPrice(tempsPrice); sarray[i].setQuantity(tempQ);
}
cout<<"done"<<endl; }
}
file format:
Red Stuff
10.5
5
20.5
Green Stuff
10.5
5
20.5
Yellow Stuff
10.5
5
20.5
Orange Stuff
10.5
5
20.5
Pepper Stuff
10.5
5
20.5
Suger Stuff
10.5
5
20.5
but im getting this:
----------------------------------------------------------
Pruduct 1 Red | 0 | 0 | 0
----------------------------------------------------------
Pruduct 2 | 0 | 0 | 0
----------------------------------------------------------
Pruduct 3 | 0 | 0 | 0
----------------------------------------------------------
Pruduct 4 | 0 | 0 | 0
----------------------------------------------------------
Pruduct 5 | 0 | 0 | 0
----------------------------------------------------------
Pruduct 6 | 0 | 0 | 0
----------------------------------------------------------
instead of:
----------------------------------------------------------
Pruduct 1 Red Stuff | 10.5 | 20.5 | 5
----------------------------------------------------------
Pruduct 2 Green Stuff | 10.5 | 20.5 | 5
----------------------------------------------------------
Pruduct 3 Yellow Stuff | 10.5 | 20.5 | 5
----------------------------------------------------------
Pruduct 4 Orange Stuff | 10.5 | 20.5 | 5
----------------------------------------------------------
Pruduct 5 Pepper Stuff | 10.5 | 20.5 | 5
----------------------------------------------------------
Pruduct 6 Suger Stuff | 10.5 | 20.5 | 5
----------------------------------------------------------
thanks