在地址从 1000 开始的 32 位系统上,以下地址值是什么?
int main()
{
int a[10];
a;
a++;
&a+1;
}
我尝试将相同的内容打印到打印语句中,但这给了我错误。
最佳答案
您无法增加固定大小数组的值,例如 int a[10]
或 char str[10]
。指针上的地址增量是可能的。
例如
char *a="abcd";
printf("%p",a); //prints the address of a lets take 1000
a++; //increments the address by 1( size of character is 1 byte);
printf("%p",a); //prints 1001
但在整数的情况下,例如
int *a={1,2,3,4};
printf("%p",a); //prints the address of a, lets take 1000
a++;
printf("%p",a) //prints 1004 (because the size of integer in 32 bit machine is 4 bytes.
关于c - 在 32 位机器上执行 C 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39816406/