我想要达到的结果
struct st{int x;int *y;} *pt;
int a[]={1,2},b[]={3,4};
struct st c[2]={10,a,20,b};
pt=c;
怎么表示能让pt指向的值为11,哪位能解释一下这串代码的意思?
struct st{int x;int *y;} *pt;
int a[]={1,2},b[]={3,4};
struct st c[2]={10,a,20,b};
pt=c;
怎么表示能让pt指向的值为11,哪位能解释一下这串代码的意思?
供参考:
#include <stdio.h>
struct st {
int x;
int* y;
} *pt;
int main()
{
int a[] = { 1,2 }, b[] = { 3,4 };
struct st c[2] = { 10,a,20,b };
pt = c; // ==> pt = &c[0];
printf("%d,%d,%d\n", pt->x, *(pt->y + 0), *(pt->y + 1));
pt++; // ==> pt = &c[1];
printf("%d,%d,%d", pt->x, pt->y[0], pt->y[1]);
return 0;
}
//输出:
//10, 1, 2
//20, 3, 4