Invalid application of sizeof to incomplete type with a struct

前端 未结 5 1760
你的背包
你的背包 2020-12-06 04:06

I have a struct where I put all the information about the players. That\'s my struct:

struct player{
   int startingCapital;
   int currentCapital;
   int s         


        
5条回答
  •  情歌与酒
    2020-12-06 04:42

    Your error is also shown when trying to access the sizeof() of an non-initialized extern array:

    extern int a[];
    sizeof(a);
    >> error: invalid application of 'sizeof' to incomplete type 'int[]'
    

    Note that you would get an array size missing error without the extern keyword.

提交回复
热议问题