Error “initializer element is not constant” when allocate the memory

后端 未结 4 1549
遥遥无期
遥遥无期 2020-12-11 05:13
  1 #include
  2 #include
  3 
  4 typedef struct node_t{
  5     int i;
  6     struct node_t* link;
  7 }node;
  8 
  9 node* head =         


        
4条回答
  •  不思量自难忘°
    2020-12-11 05:28

    You can't use malloc() in global scope. or you can do like follow

    #include
    #include
      :
    node* head
      :
      :
    int main(){
      :
      :
    head = (node *)malloc(sizeof(node));
      :
      :
    }
    

提交回复
热议问题