【发布时间】:2023-01-08 13:48:03
【问题描述】:
我正在学习变量是如何按值传递给函数的,而数组是按引用传递的。
我运行我的脚本来验证这一点,但是指针地址不同。这是为什么?
void arrayFunction(int array[4]);
int main(void){
int foo[4] = {0, 1, 2, 3};
printf("This is the address to foo in main: %p\n",&foo);
arrayFunction(foo);
}
void arrayFunction(int array[4]){
printf("This is the address to array in method: %p\n", &array);
array[0] = 22;
}
【问题讨论】:
标签: c