我在这里定义了一个函数,它接受数组作为参数
void print(char ch[]);
Run Code Online (Sandbox Code Playgroud)
当我调用该函数并将数组作为参数提供给它时
int main(){
char ch[10];
print(ch);
}
Run Code Online (Sandbox Code Playgroud)
我在两个不同的函数中打印这两个变量的地址,
#include <stdio.h>
void print(char ch[]) {
printf("address of ch is %d\n",ch);
}
int main() {
char ch[10];
print(ch);
printf("address of ch is %d\n",ch);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
main函数中数组的地址和我定义的函数中作为参数的数组地址肯定不一样,但是是一样的。为什么?
变量的地址是否可以为负数?
感谢您花时间阅读这个问题。