gpt4 book ai didi

c - 二维数组的大小

转载 作者:太空宇宙 更新时间:2023-11-04 01:07:26 25 4
gpt4 key购买 nike

<分区>

int array[][2] = {
{1,0},
{2,2},
{3,4},
{4,17}
};

int main()
{
/* calculate array size */

printf(" => number of positions to capture : %d", (int)(sizeof(array)/sizeof(array[0])));
func(array);
return 0;
}
void func(int actu[][2])
{
/* calculate array size */
printf(" => number of positions to capture : %d", (int)(sizeof(actu)/sizeof(actu[0])));
}

结果:

 => number of positions to capture : 4 -- inside main
=> number of positions to capture : 0 -- inside func -- I believe I should get 4 here too

调用和被调用函数中相同数组的大小给出了不同的值。请帮我找出问题所在。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com