Creating a singly linked list in C

后端 未结 3 1380
攒了一身酷
攒了一身酷 2021-01-13 00:58

I\'m trying to create a singly linked list from an input text file for an assignment. I\'m trying to do it a little bit at a time so I know my code is not complete. I trie

3条回答
  •  时光说笑
    2021-01-13 01:27

    You shouldn't be incrementing head after head = head->next in the for loop. PrintList will return NULL every time since the loop wont stop until head is NULL. Why do you need to return the head of the list you just passed to the function anyway?

    Edit:

    LIST *current = head;
    while (current != NULL) {
        printf("%s    %d", current->str, current->count);
        current = current->next;
    }
    

提交回复
热议问题