• 2022-06-11
    若已定义:struct Student {int num; char name[20];}stu,*p; p=&stu;,要访问stu中的num成员,可使用【】。
    A: *stu.num
    B: p->;num
    C: stu->;num
    D: p.num
  • B

    内容

    • 0

      下列选项中不能够定义一个结构体类型变量stu的是 。 A: struct student { int num; int age; } stu; B: struct student { int num; int age; }; student stu; C: struct {int num; int age; } stu; D: struct student {int num; int age; }; struct student stu;

    • 1

      分析下面的程序,下列说法中错误的是 ________ 。 #define NULL 0 #include "conio.h" struct stu { long num; char name[20]; int score; struct stu * next; }; int main() { struct stu *head,*p,*pa,*pb,*pc; pa=(struct stu *)malloc(sizeof(struct stu)); pb=(struct stu *)malloc(sizeof(struct stu)); pc=(struct stu *)malloc(sizeof(struct stu)); scanf("%ld%s%d",&pa->num,pa->name,&pa->score); scanf("%ld%s%d",&pb->num,pb->name,&pb->score); scanf("%ld%s%d",&pc->num,pc->name,&pc->score); head=pa; pa->next=pb; pb->next=pc; pc->next=NULL; p=head; while(p!=NULL) { printf("%ld,%s,%d\n",p->num,p->name,p->score); p=p->next; } }

    • 2

      当p指向结构体变量stu时,以下哪种方法无法引用成员num( )。 A: stu.num B: (*p).num C: p->;nun D: p.num

    • 3

      若有以下定义和语句:struct student { int age,num ; }; struct student stu[3]={{1001,20},{1002,19},{1003,21}}; int main() { struct student *p=stu; … }则以下正确的引用是()。 A: (p++)->num B: ++p->num C: (*p).num D: p->num

    • 4

      设有以下定义:[br][/br]struct student[br][/br]{[br][/br]int age;[br][/br]int num;[br][/br]}stu[5],*p=stu;[br][/br]int i;[br][/br]stu[0].num=10;[br][/br]则以下语句不正确的是()。 A: i=p->num B: i=stu[0].num C: i=(*p).num D: p=&student.num;