cho em hỏi lỗi chỗ nào mà nó không in ra gì nhỉ
#include<iostream>
using namespace std;
struct node{
int data;
node* pNext;
};
node* insertToLast(node* head, int x) {
node* p = new node;
p->data = x;
node* temp = head;
while ((temp->pNext) != NULL) {
temp = temp->pNext;
}
temp->pNext = p;
return head;
}
int main() {
node* head = new node;
head->data = 1;
insertToLast(head, 2);
for (node *i = head; i != NULL; i = i->pNext) {
cout << i->data << " ";
}
}