I'm having a problem with this code. Can you explain me why this is not working:

#include <stdio.h>
#include <stdlib.h>

typedef struct NODE {
    int value;
    struct NODE *next;
} Node;

int main(void) {
    Node *root = NULL, *connector;
    int n;
    printf("Enter a series of number: ");
    for(;;) {
        scanf("%d", &n);
        if(n == 0)
            break;

        connector = malloc(sizeof(Node));
        connector->value = n;
        if(root == NULL) {
            root = connector;
            root->next = NULL;
        }
            connector = connector->next;

    }
    connector->next = NULL;
    connector = root;

    while(connector->next != NULL) {
        printf("%d\n", connector->value);
        connector = connector->next;
    }

}

What is line 24 supposed to accomplish? Keep in mind that connector->next is uninitialized at this point.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.