Linked Lists

Hello I am creating a linked list program. I am getting an error below saying "expected type specifier before ""temp;". Any ideas, hints, clues? Thanks.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void add_middle_node(){

    node *current;
    current = start_ptr;

        if(current->nxt == NULL){

            add_node();
        }else{

            node *temp = new temp; // THIS IS WHERE THE ERROR OCCURS

            get_details(temp);

            temp->nxt = current->nxt;

            current->nxt = temp;

            delete temp;

        }

};
Last edited on
node *temp = new node;

new is used with data types. temp is a variable.
Yes I figured it out. Thank you Anyways Cody.

Also the "delete temp" causes a memory leak.
Last edited on
Topic archived. No new replies allowed.