为您找到"
int a=1,&b=a,*p=&a,y;表达式y=(a+=b,b+=*p,*p+a)的值?(具体过程)
"相关结果约100,000,000个
int *p=(int*)(&a+1); is undefined behavior. This is because (&a + 1) effectively shifts the pointer from the address of a by sizeof(a) (that's what the +1 does). Now the pointer is pointing to the beginning of another array of the same size as a, but not a, and not a memory location that we are actually sure is the memory of a new array.
目录1.结论2.原因 1.结论 int *p =&a, 正确写法。*p = &a, 错误写法。*p = a, 正确写法。 p = &a, 正确写法。2.原因 "&"一直都是取地址符,而" * "在1中只是声明变量,在2,3,4中则是取值符,两者含义不同。(1)在1中," * "是声明变量,即告诉计算机,我这个P是指针类型的变量,是要存放 ...
在C语言中,已知定义:int b[]={1,2,3,4},y,*p=b;执行y=*p++后,y的值为( )。求过程1楼的回答是错误的,执行*p++后并不会修改数组b中的任何值,运行y = *p++,++的优先级要高于*,所以等价于y = *(p++),由于初始化 ...
文章浏览阅读1.1k次,点赞33次,收藏30次。(1)设已定义"int a, *p;",下列赋值表达式中正确的是(A.*p=aB.p=*aC.p=&aD.*p=&a指针变量的值是地址,* 为指针运算符,选择C。(2)若已定义"int a[]={1,2,3,4},*p=a;", 则下面表达式中值不等于2的是(A.*(a+1)B.*(p+1)C.*(++a)D.*(++p)a表示数组所在地址 ...
以下内容是CSDN社区关于求助?设有说明:int a=10,b=10;,执行语句a%=b+(a&&b);后,a的值为( )相关内容,如果想了解更多关于C语言社区其他内容,请访问CSDN社区。
文章浏览阅读291次。该题考察指针和运算符的使用。根据题意,指针 `p` 指向数组的第一个元素,即 `p=&a[0]`,则 `*p=1`。根据 C 语言运算符优先级,`++` 的优先级高于 `*`
&a is of type int (*)[10] (which acts like a pointer to an array) a is of type int [10] (which acts like a pointer to a single element) So when you add 1 keep those types in mind. The pointer will be offset by the size of the type that the address contains. a+1 offsets by the size of int, i.e. to the second element in the array.
这好解释啊,因为++是后++,要等到把(*--p)的值赋给y后(*--p)的值才会增1。 所以结果是y=1,a[0]=2。 你可以用下面的代码验证:
是int*[5]类型,强制转换为(int*)后,(int *)(&a + 1)就是一个int*类型的指针了,指向a[5]. 所以p是一个指向a[5]的int*指针。 4.p-1的运算. 所以我们再来看p-1: p是一个int*型变量,所以它的大小就是一个int*型,那么p-1中,系统会认为减1是减去一个int*型的大小,所以p-1就是 ...
a++不正确。 在C语言中,对于数组名a,它是数组首元素的地址,即a表示a[0]的地址。而在指针p中,它指向了数组a的第一个元素,即p也表示a[0]的地址。