相关疑难解决方法(0)

为什么数组参数的大小与main中的大小不同?

为什么作为参数发送的数组的大小与main中的相同?

#include <stdio.h>

void PrintSize(int p_someArray[10]);

int main () {
    int myArray[10];
    printf("%d\n", sizeof(myArray)); /* As expected, 40 */
    PrintSize(myArray);/* Prints 4, not 40 */
}

void PrintSize(int p_someArray[10]){
    printf("%d\n", sizeof(p_someArray));
}
Run Code Online (Sandbox Code Playgroud)

c arrays function sizeof

101
推荐指数
7
解决办法
7万
查看次数

标签 统计

arrays ×1

c ×1

function ×1

sizeof ×1