Jul 5, 2024
A
for simplicity).struct node {
int data;
struct node* next;
};
next
can be any valid name (like link
or next
).struct Node {
int data;
Node* next;
};
Node* A = nullptr;
malloc
(C) or new
(C++).Node* temp = (Node*)malloc(sizeof(Node));
Node* temp = new Node();
temp->data = 2;
temp->next = nullptr;
A = temp;
new
in C++.Node* temp = new Node();
temp->data = 4;
temp->next = nullptr;
Node* temp1 = A;
while (temp1->next != nullptr) {
temp1 = temp1->next;
}
temp1->next = temp;
Thank you for watching!