文档详情

C语言结构体单元练习.doc

发布:2017-06-09约4.29千字共6页下载文档
文本预览下载声明
1.有以下定义和语句: struct student { int age; int num; }; struct student stu[3]={{1001,20},{1002,19},{1003,21}}; main() { struct student *p; p=stu; …… } 则以下不正确的引用是 。 A) (p++)-num B) p++ C) (*p).num D) p=stu.age 2.有以下结构体定义: struct example { int x; int y; }v1; 。 A) example.x=10 B) example v2; v2.x=10; C) struct v2; v2.x=10; D) struct example v2={10}; 3.对于如下结构体定义,若对变量person的出生年份进行赋值,正确的赋值是 。 struct date { int year,month,day; }; struct worklist { char name[20]; char sex; struct date birth; }person; A) year=1976 B) birth.year=1976 C) person.birth.year=1976 D) person.year=1976 4.根据下述定义,可以输出字符A的语句是 。 struct person { char name[11]; struct { char name[11]; int age; }other[10]; }; struct person man[10]={ {Jone,{Paul,20}},{Paul,{Mary,18}}, {Mary,{Adam,23}},{Adam,{Jone,22}} }; A) printf(%c,man[2].other[0].name[0]); B) printf(%c,other[0].name[0]); C) printf(%c,man[2].(* other[0])); D) printf(%c,man[3].name); 5.若有以下程序段: struct st { int n; struct st *next; }; struct st a[3]={5,a[1],7,a[2],9, \0} ,*p=a; 则值为6的表达式为 。 A) p++-n B) p-n++ C) (*p).n++ D) ++p-n 6.对于以下定义,不正确的叙述是 。 union data { int i; char c; float f;}a,b; A) 变量a所占的内存长度等于成员f的长度 B) 变量a的地址和它的各成员地址都是相同的 C) 不能对变量a赋初值 D) 可以在定义的时候对a初始化 7.下述程序运行结果为 。 #include stdio.h struct st { int n; int *m; }*p; void main() { int d[5]={10,20,30,40,50}; struct st arr[5]={100,d,200,d+1,300,d+2,400,d+3,500,d+4}; p=arr; printf(%d\t,++p-n); printf(%d\t,(++p)-n); printf(%d\n,++(*p-m)); } A) 101 200 21 B) 101 20 30 C) 200 101 21 D) 101 101 10 8、 。 #include stdio.h main( ) { union { long a; int b; char c;}m; printf(%d\n,sizeof(m));} A) 2 B) 4 C) 6 D) 7 9.若要利用下面的程序段使指针变量p指向一个存储整型变量的存储单元,则在空格中应填入的内容是 。 int *p; p= malloc(sizeof(int)); A) int B) int * C) (* int) D) (int *) 10、执行下述语句后的结果是
显示全部
相似文档