我正在尝试打印一些包含 integer 的整数数据0,但我想忽略包含它的数据NULL而不打印它。但我的 C 代码无法区分0和NULL并将它们视为相同。
void ecrire(struct node *p) {
if (p->data == NULL) { 'if the first node contains NULL it means list is empty'
printf("no items!\n");
return;
}
struct node *temp = p;
while (temp != NULL) {
printf("%d ", temp->data);
temp = temp->next;
}
printf("\n");
}
Run Code Online (Sandbox Code Playgroud)
当我传递第一个节点中包含值 0 的列表时,它会将其视为空列表。请问有什么解决办法吗?
c ×1