if         数组名直接作为参数压栈
then     sizeof(数组名) = 一个指针所占字节数
else     sizeof(数组名) = 数组所占字节数
测试程序如下:
typedef struct{
    
char array[32];
}node_t;

void
 fun1(node_t    node)
{
    printf(
"%d\n"sizeof(node.array));
}

void fun2(char array[32])
{
    printf(
"%d\n"sizeof(array));
}

int main(void)
{
    node_t  node;
    fun1(node); // indirect
    fun2(node.array); // direct

    
return 0;
}
程序的输出是:
32
4

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
  • 2021-06-10
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
猜你喜欢
  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
相关资源
相似解决方案