从txt文件中读取链接列表(以逗号分隔)

时间:2017-04-07 05:06:31

标签: c++ file io linked-list

我想知道从文本文件中读取链接列表的最佳方法是什么?

我目前有一个写入文件系统的工作,但我不确定如何“反转”它并填充我的链表?

他是我目前写的文件代码:

void linkedList::writeFile()
{
    ofstream myfile;
    node* thisNode = head;
    myfile.open("example.txt");

    do
    {
        myfile << thisNode->shape<< ",";
        myfile << thisNode->colour << ",";
        myfile << thisNode->size << ",";
        myfile << thisNode->type << ",";
        myfile << thisNode->volume << ",";
        myfile << thisNode->density << ",";
        myfile << thisNode->capacity << ",";
        myfile << "\n";
        thisNode = thisNode->nextNode;
    } while (thisNode != NULL);

    myfile.close();
}

我对所有建议持开放态度! :)

感谢。

0 个答案:

没有答案