Initialization from incompatible pointer type warning when assigning to a pointer

后端 未结 5 528
梦谈多话
梦谈多话 2020-12-06 16:46

GCC gives me an \'Initialization from incompatible pointer type\' warning when I use this code (though the code works fine and does what it\'s supposed to do, which is print

5条回答
  •  遥遥无期
    2020-12-06 17:24

    These are the ways to point to a (beginning of) array (without a warning), both work:

    int *q = arr;
    /* OR */
    int *q = &arr[0];
    

    This one is something in between, and will generate a warning:

    int *q = &arr;
    

提交回复
热议问题