C pointer : array variable

后端 未结 7 499
盖世英雄少女心
盖世英雄少女心 2021-01-20 18:09

I read this in my book (and many sources on the internet):

The array variable points to the first element in the array.

相关标签:
7条回答
  • 2021-01-20 19:07

    They point to the same address, i.e. printf will show the same value but they have different types.

    • The type of &msg is char(*)[16], pointer to array 16 of char
    • The type of &msg[0] is char *, pointer to char

    A cheap way to test this is to do some pointer arithmetic. Try printing &msg + 1.

    This C FAQ might prove useful.

    0 讨论(0)
提交回复
热议问题