我正在使用C ++链表和visual Studio来创建表单并将其保存到csv文件中。这里出现的问题是它工作正常,每次我添加,它都完美地添加。但是在我关闭程序并重新打开并再次添加之后,整个数据就会清除csv文件并添加一个新文件。
所以基本上当我重新运行程序时,它不会添加产品,而是删除所有然后添加。
void BootLinkedList::bootSave()
{
ofstream infile;
infile.open("footwear2.csv");
Boots *node = head;
while (node != NULL)
{
infile << node->getCode() << "," << node->getBrand() << "," << node->getColor() << "," << node->getSize() << "," << node->getPrice() << "," << node->getType() << "," << node->getSoleStyle() << "," << node->getBootType() << "," << node->getBootStyle() << "," << "-" << endl;
node = node->getNext();
}
infile.close();
}
答案 0 :(得分:0)