printf("themaxlengthoftenstringsis:
%d,%s\n",strlen(t),t);
}
A.t=s[j]B.t=&s[j]C.t=s++D.t=s[j][0]
13.下面判断正确的是()。
A.char*s="girl";等价于char*s;*s="girl";
B.chars[10]={"girl"};等价于chars[10];s[10]={"girl"};
C.char*s="girl";等价于char*s;s="girl";
D.chars[4]="boy",t[4]="boy";等价于 chars[4]=t[4]="boy"
14.设char*s="\ta\017bc";则指针变量s指向的字符串所占的字节数是()。
A.9B.5C.6D.7
15.下面程序段中,for循环的执行次数是()。
char*s="\ta\018bc";
for(;*s!
='\0';s++)printf("*");
A.9B.5C.6D.7
16.以下不能正确进行字符串赋初值的语句是()。
A.charstr[5]="good!
";
B.char*str="good!
";
C.charstr[]="good!
";
D.charstr[5]={'g','o','o','d'};
17.若指针p已正确定义,要使p指向两个连续的整型动态存储单元,不正确的语句是()。
A.p=2*(int*)malloc(sizeof(int));
B.p=(int*)malloc(2*sizeof(int));
C.p=(int*)malloc(2*2);
D.p=(int*)calloc(2,sizeof(int));
18.下面程序段的运行结果是()。
char*s="abcde";
s+=2;
printf("%d",s);
A.cdeB.字符'c'C.字符'c'的地址D.无确定的输出结果
19.设有如下的程序段:
chars[]="girl",*t;t=s;则下列叙述正确的是()。
A.s和t完全相同
B.数组s中的内容和指针变量t中的内容相等
C.s数组长度和t所指向的字符串长度相等
D.*t与s[0]相等
20.以下正确的程序段是()。
A.chars[20];B.char*s;
scanf("%s",&s);scanf("%s",s);
C.chars[20];D.chars[20],*t=s;
scanf("%s",&s[2]);scanf("%s",t[2]);
21.下面程序段的运行结果是()。
#include"stdio.h"
main()
{
intm=10,n=20;
char*format="%s,m=%d,n=%d\n";
m*=n;
printf(format,"m*=n",m,n);
}
A.format,"m*=n",m,nB.format,"m*=n"
C.m*=n,m=200,n=20D.以上结果都不对
22.以下与库函数strcpy(char*p,char*q)功能不相等的程序段是()。
A.strcpy1(char*p,char*q)
{while((*p++=*q++)!
='\0');
}
B.strcpy2(char*p,char*q)
{while((*p=*q)!
='\0')
{p++;q++;}
}
C.strcpy3(char*p,char*q)
{while(*p++=*q++);
}
D.strcpy4(char*p,char*q)
{while(*p)
*p++=*q++;
}
23.下面程序段的运行结果是()。
#include"stdio.h"
main()
{
chars[]="example!
",*t;
t=s;
while(*t!
='p')
{printf("%c",*t-32);
t++;}
}
A.EXAMPLE!
B.example!
C.EXAMD.example!
24.以下正确的程序段是()。
A.chars[]="12345",t[]="6543d21";strcpy(s,t);
B.chars[20],*t="12345";strcat(s,t);
C.chars[20]="",*t="12345";strcat(s,t);
D.char*s="12345",*t="54321";strcat(s,t);
25.以下与库函数strcmp(char*s,chat*t)的功能相等的程序段是()。
A.strcmp1(char*s,chat*t)
{for(;*s++==*t++;)
if(*s=='\0')return0;
return(*s-*t);
}
B.strcmp2(char*s,char*t)
{for(;*s++==*t++;)
if(!
*s)return0;
return(*s-*t);
C.strcmp3(char*s,char*t)
{for(;*t==*s;)
{if(!
*t)return0;
t++;
s++;}
return(*s-*t);
}
D.strcmp4(char*s,char*t)
{for(;*s==*t;s++,t++)
if(!
*s)return0;
return(*t-*s);
}
26.若有以下定义和语句:
ints[4][5],(*ps)[5];
ps=s;
则对s数组元素的正确引用形式是()。
A.ps+1B.*(ps+3)C.ps[0][2]D.*(ps+1)+3
27.不合法的main函数命令行参数表示形式是:
()。
A.main(inta,char*c[])B.main(intargc,char*argv)
C.main(intarc,char**arv)D.main(intargv,char*argc[])
28.若有说明语句:
chars[]="itisaexample.",*t="itisaexample.";则以下不正确的叙述()。
A.s表示的是第一个字符i的地址,s+1表示的是第二个字符t的地址
B.t指向另外的字符串时,字符串的长度不受限制
C.t变量中存放的地址值可以改变
D.s中只能存放16个字符
29.若已定义chars[10];则在下面表达式中不表示s[1]地址的是()。
A.s+1B.s++C.&s[0]+1D.&s[1]
30.下面程序段的运行结果是()。
(注:
└┘代表空格)
#include"stdio.h"
main()
{chars[6];
s="abcd";
printf("\"%s\"\n",s);
}
A."abcd"B."abcd└┘"C.\"abcd\"D.编译出错
31.执行以下程序后,a的值为【1】,b的值为【2】。
#include
main()
{
inta,b,k=4,m=6,*p=&k,*q=&m;
a=p==&m;
b=(-*p)/(*q)+7;
printf("a=%d\n",a);
printf("b=%d\n",b);
}
【1】A.-1B.1C.0D.4
【2】A.5B.6C.7D.10
32.下面程序的功能是将字符串s的所有字符传送到字符串t中,要求每传递三个字符后再存放一个空格,例如字符串s为"abcdefg",则字符串t为"abcdefg",请选择填空。
#include"stdio.h"
#include"string.h"
main()
{
intj,k=0;
chars[60],t[100],*p;
p=s;
gets(p);
while(*p)
{for(j=1;j<=3&&*p;【1】)t[k]=*p;
if(【2】){t[k]='';k++;}
}
t[k]='\0';
puts(t);
}
【1】A.p++B.p++,k++C.p++,k++,j++D.k++,j++
【2】A.j==4B.*p=='\0'C.!
*pD.j!
=4
33.下面程序的功能是将八进制正整数字符串转换为十进制整数。
请选择填空。
#include"stdio.h"
#include"string.h"
main()
{
char*t,s[8];
intn;
t=s;
gets(t);
n=【1】;
while(【2】!
='\0')n=n*8+*t-'0';
printf("%d\n",n);
}
【1】A.0B.*tC.*t-'0'D.*t+'0'
【2】A.*tB.*t++C.*(++t)D.t
34.下面程序的功能是在字符串s中找出最大的字符并放在第一个位置上,并将该字符前的原字符往后顺序移动,如:
boy&girl变成ybo&girl。
请选择填空。
#include"stdio.h"
#include"string.h"
main()
{
chars[80],*t,max,*w;
t=s;
gets(t);
max=*(t++);
while(*t!
='\0')
{
if(max<*t)
{max=*t;w=t;}
t++;
}
t=w;
while(【1】)
{
*t=*(t-1);
【2】;}
*t=max;
puts(t);
}
【1】A.t>sB.t>=sC.*t>s[0]D.*t>=s[0]
【2】A.t++B.s--C.t--D.w--
35.以下程序的功能是删除字符串s中的所有空格(包括TAB符、回车符),请填空。
#include"stdio.h"
#include"string.h"
#include"ctype.h"
main()
{
chars[80];
gets(s);
delspace(s);
puts(s);
}
delspace(char*t)
{
intm,n;
charc[80];
for(m=0,n=0;【1】;m++)
if(!
isspace(【2】))/*C语言提供的库函数,用以判断字符是否为空格*/
{
c[n]=t[m];
n++;
}
c[n]='\0';
strcpy(t,c);
}
【1】A.t[m]B.!
t[m]C.t[m]='\0'D.t[m]=='\0'
【2】A.t+mB.*c[m]C.*(t+m)D.*(c+m)
36.下面程序的功能是统计字串sub在母串s中出现的次数。
请选择填空。
#include"stdio.h"
#include"string.h"
main()
{
chars[80],sub[80];
intn;
gets(s);
gets(sub);
printf("%d\n",count(s,sub));
}
intcount(char*p,char*q)
{
intm,n,k,num=0;
for(m=0;p[m];m++)
for(【1】,k=0;q[k]==p[n];k++,n++)
if(q[【2】]=='\0')
{num++;break;}
return(num);
}
【1】A.n=m+1B.n=mC.n=0D.n=1
【2】A.kB.k++C.k+1D.++k
37.下列程序的输出结果是()。
#include"stdio.h"
main()
{
inta[]={1,2,3,4,5,6,7,8,9,0},*p;
p=a;
printf("%d\n",*p+9);
}
A.0B.1C.10D.9
38.以下程序的输出结果是()。
#include"stdio.h"
charcchar(charch)
{
if(ch>='A'&&ch<='Z')ch=ch-'A'+'a';
returnch;
}
main()
{
chars[]="ABC+abc=defDEF",*p=s;
while(*p)
{
*p=cchar(*p);
p++;
}
printf("%s\n",s);
}
A.abc+ABC=DEFdefB.abcaABCDEFdef
C.abc+abc=defdefD.abcabcdefdef
39.以下程序的输出结果是()。
#include"stdio.h"
#include"string.h"
main()
{
charb1[8]="abcdefg",b2[8],*pb=b1+3;
while(--pb>=b1)strcpy(b2,pb);
printf("%d\n",strlen(b2));
}
A.8B.3C.1D.7
40.有以下程序
#include"string.h"
#include"stdio.h"
main()
{
char*p="abcde\0fghjik\0";
printf("%d\n",strlen(p));
}
程序运行后的输出结果是()。
A.12B.15C.6D.5
41.有以下程序
voidss(char*s,chart)
{
while(*s)
{if(*s==t)*s=t-'a'+'A';
s++;
}
}
main()
{
charstr[100]="abcddfefdbd",c='d';
ss(str,c);
printf("%s\n",str1);
}
程序运行后的输出结果是()。
A.ABCDDEFEDBDB.abcDDfefDbDC.abcAAfefAbAD.Abcddfefdbd
42.以下程序调用findmax函数返回数组中的最大值。
在下面划线处应填入的是()。
#include"stdio.h"
findmax(int*a,intn)
{
int*p,*s;
for(p=a,s=a;p-aif(__________)s=p;
return(*s);
}
main()
{
intx[5]={12,21,13,6,18};
printf("%d\n",findmax(x,5));
}
A.p>sB.*p>*sC.a[p]>a[s]D.p-a>p-s
43.有以下程序
#include"stdio.h"
#include"malloc.h"
main()
{
char*q,*p;
p=(char*)malloc(sizeof(char)*20);/*为指针p分配一个地址*/
q=p;
scanf("%s%s",p,q);
printf("%s%s\n",p,q);
}
若从键盘输入:
abcdef↙,则输出结果是:
A.defdefB.abcdefC.abcdD.dd
44.下面程序的运行结果是()。
#include"stdio.h"
#include"string.h"
fun(char*s)
{
chart[10];
s=t;
strcpy(t,"example");
}
main()
{
char*s;
fun(s);
puts(s);
}
A.example└┘└┘└┘B.example└┘└┘C.exampleD.不确定的值
45.下列程序段的输出结果是()。
#include"stdio.h"
voidfun(int*x,int*y)
{
printf("%d%d",*x,*y);
*x=3;
*y=4;
}
main()
{
intx=1,y=2;
fun(&y,&x);
printf("%d%d",x,y);
}
A.2143B.1212C.1234D.2112
46.下列程序的输出结果是()。
#include"stdio.h"
main()
{
chara[10]={9,8,7,6,5,4,3,2,1,0},*p=a+5;
printf("%d",*--p);
}
A.非法B.a[4]的地址C.5D.3
47.有以下程序
#include"stdio.h"
#include"string.h"
main(intargc,char*argv[])
{
intm,length=0;
for(m=1;mprintf("%d\n",length);
}
程序编译连接后生成的可执行文件是file.exe,若执行时输入带参数的命令行是:
file123456789↙
则运行结果是()。
A.22B.17C.12D.9
48.有以下函数:
char*fun(char*s)
{…
returns;
}
该函数的返回值是()。
A.无确定值B.形参s中存放的地址值
C.一个临时存储单元的地址D.形参s自身的地址值
49.假定下列程序的可执行文件名为file.exe,则在该程序所在的子目录下输入命令行:
filegirlboy↙
后,程序的输出结果是()。
#include"stdio.h"
main(intargc,char*argv[])
{
intm;
if(argc<=0)return;
for(m=1;mprintf("%c",*argv[m]);
}
A.girlboyB.gbC.girD.girlboy
50.设有一个名为file的C源程序,且已知命令行为:
file