When I allocate nodes and copy a string (passed from another function) into the nodes it seems to work fine, all strings are copied into different nodes, however the last string in the last node doesn't seem to attach to the list, hence when I return the head and then try printing it out later, the last string is missing, because the last node never attached, I don't see why that is happening.
Code:
node = makeNode();
node->text = malloc (len * sizeof(char));
if (head == NULL) {
head = node;
tail = node;
strcpy(head->text, string);
printf("%s\n", head->text;
N++;
}
else {
tail->next = node;
prev = tail;
next = node;
tail = tail->next;
strcpy(tail->text, string);
printf("%s\n", tail->text;
N++;
}
return (head);