So i've been working on this non-stop and I got to where i can insert the characters into the dlist character by character. The problem I am now facing, and I think i might have to re-do some of my code to get this to work, is inserting the characters up to a null terminator into my doubly linked list.
Code:
while ( (x = fgetc(fp)) != EOF){
if (x == '\n')
x = '\0';
fprintf(stderr, " x is %c.\n", x);
data += ins_dlist(x, &p);
fprintf(stderr, "Inserting %c into data.\nData is %s.\n", x, data);
if (x == '\n'){
ins_dlist('\0', &p);
fprintf(stderr, "Data is %s before going into the ins_llist loop.\n", data);
}
}
Is what I am using right now to read into the dlist. The part that is in red is what im trying to use as the strings to insert into the llist, but its coming up as garbage when i print out what it is. The return of a char is fine, and i know the x is the character it needs to be... but its somewhere after i cat it with data that its getting messed up. Is there another way to do this that is alot easier or am i just blowing this big time?