You are here:

C++/linked lists & file handling

Advertisement


Question
How to read a linked list from a file into another link list?

Answer
Hello,

I would start by making a temporary linked list that holds the node values you read from a file.

while(!feof(pFile))
{
Node* pNode = new Node;
fscanf("%d", &pNode->iValue);
list.push_back(pNode);
}

After that completes, you can memcpy into your permanent list from the temp list above. Also, the list above was assuming we were storing ints for simplicity.

I hope this information was useful.

- Eddie

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Eddie

Expertise

I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.

Experience

I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 About.com. All rights reserved.