When is an array name or a function name 'converted' into a pointer ? (in C)

前端 未结 4 1491
梦毁少年i
梦毁少年i 2020-11-27 16:14

1) Misconception :

  • Whenever an array is declared in C language, a pointer to the first element of the array is created (

4条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 16:15

    The short answer is yes...except for sometimes. Usually after an array is declared, each time its name is used, it is converted to a pointer to the array object's first element. However there are some cases where this does not occur. These cases where this does not occur can be found in @KeithThompson's answer here.

    Similarly to your array, a function type will also be converted to a pointer value...except for sometimes. The cases where this does not occur again can be found at @KeithThompson's answer again. here.

提交回复
热议问题