I am working on a program where I need to read data from a file then store each line into a doubly linked list. I then need to be able to format the strings by doing things like converting uppercase to lowercase, separating numbers from letters (EX: abc123 = abc 123), and deleting symbols.
I know how to do the formatting when I read the data into an array, but I am new to linked lists and have little to no clue how to get started with this. I am currently raiding the internet for linked list tutorials, but I thought something more specific to my problem would be more helpful.
I am an amateur, so bare with me.
Thanks in advance!
Oh... and I am not allowed to use the linked list template in the STL library.
EDIT: Ok so I found out that I need to make a linked list for each line that is in the file (each word in the line is a node), and then I need to make a linked list containing the lists that contain the lines (each node is a list containing the words in a line).
I'm trying to figure out how I would do this last bit. I'm still learning about Linked Lists, but I'm wondering if it would be easier to get the data out of the file and store it in an array or something, then store that into the lists. The issue I have with that is that that would mean seperating the file into lines, then seperating lines into words, and that sounds more complicated than I think this is supposed to be.
Hopefully you can store the strings using std::string.
Doubly linked lists come up here frequently. Search the forum and look at some of the questions and answers. Some common problems that people seem to run into:
- Not separating the list from the nodes within it. The two should be separate classes.
- Not taking care of both the "prev" and "next" pointers when modifying the list.