0
Linked list c++
Can some help me to traverse the current list and remove error and warnings from this code. https://code.sololearn.com/czsvFDPwhqNM
3 Respostas
+ 3
Correct code,
void insertion(struct Node *node,int data){
if(node->next==NULL and node->data != 0){
Node *temp = new Node();
temp->data = data;
node->next = temp;
}else if(node->next == 0 and node->data == 0 ){
node->data = data;
}
}
void traverse(struct Node *head){
while(head){
cout<<head->data;
head = head->next;
};
}
to get rid of warning i replaced NULL with 0 .
+ 1
these are some of the mistakes you are making.
struct Node{
int data;
Node *next;
};
void insertion(Node *node, int data){
void traverse(Node *head){
if(node->next == NULL && node->data != 0) {
} else if(node->next == 0 && node->data == 0 ){
https://www.cprogramming.com/tutorial/lesson15.html
Keep learning & happy coding :D