(36)设有定义:
struct complex
{ int real,unreal;} data1={1,8},data2;
则以下赋值语句中错误的是
A)data2=data1;
B)data2=(2,6);
C)data2.real=data1.real;
D)data2.real=data1.unreal;
(37)有以下程序
#include
#include
struct A
{ int a; char b[10]; double c;};
void f(struct A t);
main()
{ struct A a={1001,"ZhangDa",1098.0};
f(a); printf("%d,%s,%6.1f\n",a.a,a.b,a.c);
}
void f(struct A t)
{ t.a=1002; strcpy(t.b,"ChangRong");t.c=1202.0;}
程序运行后的输出结果是
A)1001,zhangDa,1098.0
B)1002,changRong,1202.0
C)1001,ehangRong,1098.O
D)1002,ZhangDa,1202.0
(38)有以下定义和语句
struct workers
{ int num;char name[20];char c;
struct
{int day; int month; int year;} s;
};
struct workers w,*pw;
pw=&w;
能给w中year成员赋1980的语句是
A)*pw.year=198O;
B)w.year=1980;
C)pw->year=1980;
D)w.s.year=1980;
(39)有以下程序
#include
main()
{ int a=2,b=2,c=2;
printf("%d\n",a/b&c);
}
程序运行后的输出结果是
A)O
B)1
C)2
D)3
(40)有以下程序
#include
main()
{ FILE *fp;char str[10];
fp=fopen("myfile.dat","w");
fputs("abc",fp);fclose(fp);
fpfopen("myfile.data","a++");
fprintf(fp,"%d",28);
rewind(fp);
fscanf(fp,"%s",str); puts(str);
fclose(fp);
}
程序运行后的输出结果是
A)abc
B) 28c
C) abc28
D)因类型不一致而出错