1,
struct stu{
int x;
int *y;
} *p;
int dt[4] = {10, 20, 30, 40};
struct stu a[4] = {50, &dt[0], 60, &dt[1], 70, &dt[2], 80, &dt[3]};
int main( )
{
p=a;
printf("%d,", ++p->x); //p->x 值为50,之后++50==51
printf("%d,", (++p)->x);//(++p)表达式值为a[1],同时p向之后移一个单位。之后a[1]-->x 值为60
printf("%d", ++(*p->y));//p->y 值为&dt[1],++20==21
return 0;
}
输出:
51,60,21
2,如果结构变量s中的生日是“1984年11月11日”,下列对其生日的正确赋值是(A)
struct student
{
int no;
char name[20];
char sex;
struct{
int year;
int month;
int day;
}birth;
};
struct student s;
---------------------------
struct add {
int year;
int month;
int day;
};
struct student
{
int no;
char name[20];
struct add birth;
char sex;
};
struct student s;
A.s.birth.year = 1984; s.birth.month = 11; s.birth.day=11;
B.birth.year = 1984; birth.month = 11; birth.day = 11;
C.s.year = 1984; s.month = 11; s.day = 11;
D.year = 1984; month = 11; day = 11;