Error: Conversion to non-scalar type requested

后端 未结 3 643
灰色年华
灰色年华 2021-02-04 05:04

I\'m having a small problem trying to malloc this struct. Here is the code for the structure:

typedef struct stats {                  
    int strength;                  


        
3条回答
  •  情歌与酒
    2021-02-04 05:30

    The memory assigned by malloc must be stored in a pointer to an object, not in the object itself:

    dungeon *d1 = malloc(sizeof(dungeon));
    

提交回复
热议问题