#include <stdio.h>
#include <stdlib.h>
struct Node
{
int data;
struct Node *next;
};
int main()
{
struct Node* head;
head->data = 1;
head->next = NULL;
printf("%d", head->data);
return 0;
}
为什么这一段代码不能运行?
另外还有 warning:'head' is uninitialized in this function ?
调试运行到 head 就崩了。。。
编译器已经给你提示了,指针没有初始化呀~~~
要么改成这样:
要么改成: