struct data
{
string pName;
string pCat;
int pBarcode;
double pPrice;
string pMan;
int pStock;
int pSold;
data *next;
data *prev;
};
This is my text file:
3 Kidney Vetch Team Sports 157541796 8601.14 Kelloggs 465 100 Kidney Vetch Food 971324986 1526.55 Fisher Price 845 466 Tea Tree Breakfast Foods 861165080 2281.0 Purina One 186 803
This is my function:
void Interface::dataTxt(){
int noItem,i;
ifstream datas("data-xs");
datas >> noItem;
for(i=0;i<noItem;i++){
cin>>data.ppName;
cin>>data.pCat;
cin>>data.pBarcode;
cin>>data.pPrice;
cin>>data.pMan;
cin>>data.pStock;
cin>>data.pSold;
}
infile.close();
}
The structure is in my database.h, and the function is in my interface.cpp there is a interface.h too where i #include "database.h"
I am having quite alot errors. May i noe if that is the correct way to read in a text file into array of struture? the first number in the text file is the number of item in the file.

New Topic/Question
Reply




MultiQuote





|