What I need to do, is for every line of my input (which is unknown until runtime), I need to create a struct and pass the struct to a list. To function to append stuff to the end of a list is dll_append(Dllist *list, void *node_value).
What keeps confusing me, is how to make a different struct for every line in the file. Furthermore, even if I just pass one struct and then try to extract say a name field of the struct, I just get random characters.
I don't have a problem with the list thing. Technically I could use an array, but lists are easier because I have to sort it later.
Basically, I'm reading in data like so:
Name, age, height , eye color, etc
So I need a struct to hold all the info for each person per line. Now, I can pass one struct ok, but if I have multiple lines of input, I just keep writing over my previous struct. Furthermore, whenever I attempt to pull my struct back out of the list, I just get random characters (which is probably a pointer problem - I'm more concerned with the first issue).
@chrisname - Something like that might work, I'll try it out.
I would make a function called "GetLine()" or something similar, which takes a FILE* and returns a myStruct* (or you could pass it in if you wanted), and then reads enough information from the file.
Well, I'm using a get_line to read in the lines, but it's not my library. It returns a struct that allows me to grab each word in the line throughchar *token = strdup(input_struct->fields[i]). But, once again, it only gets written over with every call of get_line(input).