struct ord
{ int x,y; } dt[2]={1,2,3,4};
//相当于struct ord dt[2], 其中dt[0].x= 1;dt[0].y= 2;dt[1].x= 3;dt[1].y= 4;
struct ord *p=dt;
//指针p指向了dt, 也就是dt[0]的第一个成员, dt[0].x, 它的基类型是struct ord;
printf("%d,",++(p->x)); printf("%d\n",++(p->y));
//此时的p->x就是dt[0].x, 于是p->x = 1, 是前++, 所以第一句输出2. p->y = dt[0].y = 2, 同理, 就是3;
#include
struct ord
{
int x,y;
} dt[2]={1,2,3,4}; //初始化结构体
main()
{
struct ord *p=dt; //定义结构体指针p
printf("%d,",++(p->x)); //x对应结构体数值1
printf("%d\n",++(p->y)); //y对应结构体数值2
}
如有疑问,百度HI我!
#include
struct ord
{ int x,y; } dt[2]={1,2,3,4}; //这里定义了2个结构体对象 dt[0],dt[1]
main() //拆开就是dt[0]={1,2} , dt[1]={3,4}
{
struct ord *p=dt;
printf("%d,",++(p->x)); printf("%d\n",++(p->y)); //(p->x)指向里面的数据x,外面++就是取得的x再+1
}