Linked List Error

Feb 8, 2017 at 12:02am
I'm currently getting a Syntax error on my code and I'm unsure of what the error means and where or why it may be occurring.

Error-

/tmp/ccYtaeHG.o: In function `main':
prog.cpp:(.text+0xf6): undefined reference to `AddNode(node*, int)'
collect2: error: ld returned 1 exit status

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
node *addNode (node *head, int value){
    node *x = new node;
    x -> key = value;
    x -> next = NULL;
    if (head == NULL){
        head = x;
    }
    else {
        if (head -> next == NULL){
            head -> next = x;
        }
        else {
            node *temp = head;
            while (temp -> next != NULL){
                if (temp -> next == NULL) {
                    temp -> next = x;
                }
                temp = temp -> next;
            }
        }
    }
    return head;
}
Feb 8, 2017 at 2:47am
addNode (line 1) vs AddNode (error message)
Feb 8, 2017 at 5:46am
wow.... I can't believe I missed that thank you.
Feb 8, 2017 at 2:30pm
If possible. add the node to the beginning of the list instead of the end. It will be faster when the list is large, and it's much less code.
Topic archived. No new replies allowed.