Apr 2, 2014 at 10:27pm UTC
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 Apr 2, 2014 at 10:27pm UTC
Apr 2, 2014 at 10:37pm UTC
node *temp = new node;
new is used with data types. temp is a variable.
Apr 2, 2014 at 10:51pm UTC
Yes I figured it out. Thank you Anyways Cody.
Also the "delete temp" causes a memory leak.
Last edited on Apr 2, 2014 at 10:57pm UTC