为什么用malloc会报错呀

原本想要让这个指针指向NULL好像只能这样办,用了malloc但是会报错

img

你要放在函数里面

语句没错,你得把这条语句放到函数里,函数外不能调用函数。例如:

struct node * create(){
  struct node * head=(struct node *)malloc(sizeof(struct node));
  return head;
}