Answer the question
In order to leave comments, you need to log in
What's wrong with l buffersmall?
void read_database (Products**Ps) {
ifstream file;
Products*Inc=new Products;
Product S;
file.open("database.txt",ios::in);
if (!file) {
cout<<rus("База данных не доступна");
return;
}
long file_size;
file.seekg(0, ios::end);
file_size = file.tellg();
if (!file_size) {
cout<<rus("База данных пуста");
return;
}
file.close();
file.open("database.txt",ios::in);
file.read((char *) &S, sizeof(Product));
Inc->P.id=S.id;
strcpy_s(Inc->P.name, S.name);
strcpy_s(Inc->P.value, S.value);
Inc->P.price=S.price;
Inc->P.number=S.number;
strcpy_s(Inc->P.last_date, S.last_date);
Inc->next=NULL;
*Ps=Inc;
while(!file.eof()) {
Inc->next=new Products;
Inc=Inc->next;
Inc->P.id=S.id;
strcpy_s(Inc->P.name, S.name);
strcpy_s(Inc->P.value, S.value);
Inc->P.price=S.price;
Inc->P.number=S.number;
strcpy_s(Inc->P.last_date, S.last_date);
Inc->next=NULL;
}
file.close();
cout<<"-------------------------------"<<endl;
cout<<rus("Список товаров получен из файла")<<endl;
cout<<"-------------------------------"<<endl;
}
File: f:\dd\vctools\crt_bld\self_x86\crt\ src\tcscpy_s.inl
Line: 30
Expression: (L "Buffer is too small" && 0)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question