Why am I getting this error: “data definition has no type or storage class”?

后端 未结 4 1358
北荒
北荒 2021-02-06 01:11
#include 
#include 

struct NODE {
    char* name;
    int val;
    struct NODE* next;
};
typedef struct NODE Node;

Node *head, *tail;
he         


        
4条回答
  •  眼角桃花
    2021-02-06 01:56

    You need to put your code inside a function:

    #include 
    #include 
    
    struct NODE {
        char* name;
        int val;
        struct NODE* next;
    };
    typedef struct NODE Node;
    
    main(){
        Node *head, *tail;
        head = (Node*) malloc( sizeof( Node ) ); //line 21
    }
    

    should work

提交回复
热议问题