若有如下定义和声明: struct s { int m;char ch;double x; union t {char a[6];int b[3];}tt;}ss; 则sizeof(struets)的值是( )
A.6
B.14
C.17
D.20
第1题:
已知有变量datal定义如下: union data { int i; char ch; float f; }datal; 则变量datal所占的内存存储空间可表示为(57)。
A.sizeof(int)
B.sizeof(char)
C.sizeof(float)
D.SiZCOf(mt)+sizeof(char)+sizeof(float)
第2题:
● 已知有变量 data1 定义如下:
union data
{ int i;
char ch;
float f;
} data1;
则变量 data1 所占的内存存储空间可表示为 (57) 。
(57)
A. sizeof(int)
B. sizeof(char)
C. sizeof(float)
D. sizeof(int)+sizeof(char)+sizeof(float)
第3题:
若有以下定义和语句
union data
{ int i; char c; float f; } x;
int y;
则以下语句正确的是
A)x=10.5;
B)x.c=101;
C)y=x;
D)printf("%d\n",x);
第4题:
下列程序的功能是:求出ss字符串中指定字符c的个数,并返回此值。请编写函数int num(*char ss,char c)以实现程序要求,最后调用函数readwriteDat(),把结果输出到文件out.dat中(注:大小写字母有区别)。例如:若输入字符串“ss="123412132" , c=’1’”,则输出“3”。部分源程序已给出。请勿改动主函数main()和输出数据函数writeDat()的内容。#include <conio.h>#include <stdio.h>#define M 81void readwriteDAT(); int num(char *ss,char c){ } main(){ char a[M],ch; clrscr(); printf("\nPlease enter a string:" );gets(a); printf("\nPlease enter a char;" );ch=getchar(); printf("\nThe number of the char is:%d\n" ,num(a,ch)); readwriteDAT();}viod readwriteDAT(){ int i; FILE *rf,*wf; char a[M],b[M],ch; rf=fopen("in.dat" ,"r" ); wf=fopen(" out.dat" ,"w" ); for(i=0;i<10;i++){ fscanf(rf," %s",a); fscanf(rf," %s" ,b); ch=*b; fprintf(wf," %c=%d\n:" ,ch,num(a,ch));} fclose(rf); fclose(wf);}
第5题:
若有下面的说明和定义
struct test
{ int ml; char m2; float m3;
union uu {char ul[5]; int u2[2];} ua;
} myaa;
则sizeof(struct test )的值是
A.12
B.16
C.14
D.9
第6题:
下面程序的输m结果是( )。 typedef union {double x[3]; int y[4]; char z[10]; }M; M t; main() { Printf("%d\n",sizeof(t));}
A.32
B.26
C.24
D.4
第7题:
下列程序的功能是:求出ss所指字符串中指定字符的个数,并返回此值。
例如,若输入字符串123412132,输入字符1,则输出3,请填空。
#include
#include
#define M 81
int fun(char *ss, char c)
{ int i=0;
for(; ( );ss++)
if(*ss==c)i++;
return i;}
main()
{ char a[M], ch;
clrscr();
printf("\nPlease enter a string: "); gets(a);
printf("\nPlease enter a char: "); ch=getchar();
printf("\nThe number of the char is: %d\n", fun(a,ch));}
第8题:
若有下面说明和定义:struct test{ int m1;char m2;float m3;union uu(char u1[5];int u2[2];)ua;}myaa; 则sizeof(struct test)的值是( )。A)20 B)16C)14 D)9
第9题:
●在某嵌入式系统中,采用PowerPC处理器,若定义了如下的数据类型变量X,则X所占用的内存字节数是(52).
union data{
int i;
char ch;
double f;
} X;
(52) A.8
B.3
c.16
D.24
第10题:
下列对结构及其变量定义错误的是( )。
A.struct My Struct
B.struct MyStruct{ {int num; int num;char ch; char ch;} }My;
C.strut
D.struct{ {int num; int num;char ch; char ch;}My; };