gpt4 book ai didi

c - 带数组和指针的 sizeof

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

<分区>

您能否解释一下为什么下面的代码会产生不同的结果。使用 netbeans。

    #define SIZE 1

size_t getSize( float *ptr );

int main( void ) {

float array[ SIZE ];
//not getting the same results??? from sizeof/getSize

printf( "The number of bytes in the array is %u\n"
"The number of bytes returned by getSize is %u\n",
sizeof( array ), getSize( array ) );
}
//sizeof( array ) prints 4
//getSize( array ) prints 8

size_t getSize( float *ptr ) {
return sizeof( ptr );
}

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