struct m { int x; int *y; }*p; int a[4]={12,13,-40,100};
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/09 10:56:20
struct m { int x; int *y; }*p; int a[4]={12,13,-40,100};
struct m b[4]={10,&a[2],9,&a[3],8,&a[0],7,&a[7]};
若p=b;
printf("%d\n",++p->x);
printf("%d\n",p->x);
为什么两个输出的都是11?(VC++6.0)
struct m b[4]={10,&a[2],9,&a[3],8,&a[0],7,&a[7]};
若p=b;
printf("%d\n",++p->x);
printf("%d\n",p->x);
为什么两个输出的都是11?(VC++6.0)
由于p=b,即p指向b所在内存
p->x就是b[0].x,所以等于10
printf("%d\n",++p->x); 中++在前,即先进行+1再返回值给printf,所以输出11
为什么后面的也是11呢,举个例子y=1,y++后y=2了,知道了吧,所以p->x值已经变为11了
所以第二个输出也是11
再问: p->x也是等于11,是不是吧(p->x)当做一个变量了?很难理解了。printf("%d\n",*p->y);输出是-40,说明p还是指向b[0]的吧。为什么呢?谢谢!
再答: 对就是把(p->x)当做了一个变量了,p是个指针吧,他保存的就是数组b的首地址嘛,所以p指向的是b[0]了,对p的操作就是对b[0]的操作了,理解了吧
p->x就是b[0].x,所以等于10
printf("%d\n",++p->x); 中++在前,即先进行+1再返回值给printf,所以输出11
为什么后面的也是11呢,举个例子y=1,y++后y=2了,知道了吧,所以p->x值已经变为11了
所以第二个输出也是11
再问: p->x也是等于11,是不是吧(p->x)当做一个变量了?很难理解了。printf("%d\n",*p->y);输出是-40,说明p还是指向b[0]的吧。为什么呢?谢谢!
再答: 对就是把(p->x)当做了一个变量了,p是个指针吧,他保存的就是数组b的首地址嘛,所以p指向的是b[0]了,对p的操作就是对b[0]的操作了,理解了吧
struct m { int x; int *y; }*p; int a[4]={12,13,-40,100};
Struct Struct st {int x;int *y;}*pt; Int a[]={1,2},b[]={3,4}
struct st{int x,int*y;}*p; int s[]={5,6,7,8} st a[]={10,&s[0
struct st{int x;int*y;}*p;inta[]={1,2},b[]={3,4};struct st c
1. 有如下定义: struct {int x; int y; } s[2]={{1,2},{3,4}},*p=s; 写
#includeint a(int x);int b(int y);int main(){int m,n;n=6;m=a
C语言习题(结构 )单选题1.有以下定义:struct { int x;int y;} a={ 5,7},*p=&a;
struct { int x; char *y; }tab[2]={{1,"ab"},{2,"cd"}},*p=tab;
struct S { int i; int * p;}; main () {S s ; int *p =&s.i ; p
以下程序的输出结果是 struct HAR {int x,y; struct HAR *P;} h[2]; main()
#include struct ord { int x,y;} dt[2]={1,2,3,4}; main() {str
fun(int x,int y,int z) {z=x*x+y*y;} main() {int a=31; fun(5,