Tag: listdef

使用数组创建单链接列表时出现警告

#include typedef struct { int data; struct node *next; }node; void print(node *head) { node *tmp = head; while (tmp) { printf (“%d “, tmp->data); tmp = tmp->next; } } int main() { node arr[5] = { {1, &arr[1]}, {2, &arr[2]}, {3, &arr[3]}, {4, &arr[4]}, {5, NULL} }; print(arr); return 0; } 为什么在使用gcc -Wall编译时会收到这些警告? (即使没有-Wall,gcc会产生相同的警告) […]