Dotcpp  >  试卷列表  >  C语言字符串

C语言字符串


第1题

下面是有关C语言字符数组的描述,其中错误的是()。

共 1 分 

第2题

以下叙述中正确的是()。

共 1 分 

第3题

以下正确的字符串常量是()。

共 1 分 

第4题

以下能正确定义字符串的语句是()。

共 1 分 

第5题

设有以下定义:

1
2
char s1[]="0123";
char s2[]={'0','1','2','3'};

则以下叙述正确的是()。

共 1 分 

第6题

以下选项中,合法的是()。

共 1 分 

第7题

以下能正确进行字符串赋值的语句组是()。

共 1 分 

第8题

以下涉及字符串数组、字符指针的程序段,不会产生编译错误的是()。

共 1 分 

第9题

有以下程序:

1
2
3
4
5
6
7
#include <stdio.h>
#include <string.h>
main()
{
    char str[12]={'s''t''r''I''n''g'};
    printf("%d\n",strlen(str));
}

程序运行后的输出结果是()。

共 1 分 

第10题

有以下程序:

1
2
3
4
5
6
7
8
9
#include <stdio.h>
main()
{
    char s[] = "012xy\08s34f4w2";
    int i,n = 0;
    for(i = 0;s[i]!='0';i++)
        if(s[i]>'0'&& s[i]<='9')n++;
    printf("%d\n",n);
}

程序运行后的输出结果是()。

共 1 分 

第11题

有以下程序:

1
2
3
4
5
6
7
#include <stdio.h>
main(){
    char s[]={"012xy"};
    int i,n=0;
    for(i=0;s[i]!=0;i++)  if(s[i]>='a'&&s[i]<='z')n++;
    printf("%d\n",n);
}

程序运行后的输出结果是()。

共 1 分 

第12题

有以下程序:

1
2
3
4
5
6
7
8
#include <stdio.h>
main()
{
    char name[10] = {'S','T','R'};
    name[2]='#';
    name[6]=0;
    printf("%s\n",name);
}

程序运行后的输出结果是()。

共 1 分 

第13题

有如下程序:

1
2
3
4
5
6
7
8
#include <stdio.h>
main()
{
    char name[10] = {'S','T','R','I','N','G'};
    name[3]='E';
    name[5]=0;
    printf("%s\n",name);
}

程序运行后的输出结果是()。

共 1 分 

第14题

有以下程序:

1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
main()
{
    int i,j=0;
    char a[] = "How are you!",b[10]={0};
    for(i=0;a[i];i++)
        if(a[i]==' ')
            b[j++]=a[i-1];
    printf("%s\n",b);
}

程序运行后的输出结果是()。

共 1 分 

第15题

有以下程序:

1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
main()
{
    int i,j=0;
    char a[] = "How are you",b[10]={0};
    for(i=0;a[i];i++)
        if(a[i]==' ')
            b[j++]=a[i+1];
    printf("%s\n",b);
}

程序运行后的输出结果是()。

共 1 分 

第16题

以下选项中正确的语句组是()。

共 1 分 

第17题

以下使指针指向一个字符串的选项错误的是()。

共 1 分 

第18题

下列语句中,正确的是()。

共 1 分 

第19题

下面选项中的程序段,没有编译错误的是()。


共 1 分 

第20题

以下叙述中正确的是()。

共 1 分 

第21题

设有如下程序段:

1
2
char s[20]= "Bejing",*p;
p=s:

则执行p=s;语句后,以下叙述正确的是()。

共 1 分 

第22题

设有定义:char *c;以下选项中能够使字符型指针c正确指向一个字符串的是()。

共 1 分 

第23题

有以下说明语句:

1
char *s = "'Name\\Address\n";

指针s所指字符串的长度是( )。

共 1 分 

第24题

若有说明和语句:

1
char str[]="Hello", *p; p=str;

则此时*(p+5)中的值为()。

共 1 分 

第25题

有以下程序:

1
2
3
4
5
6
#include <stdio.h>
main()
{
    char s[]="rstuv";
    printf("%c\n",*s+2);
}

程序运行后的输出结果是()。

共 1 分 

第26题

有以下程序

1
2
3
4
5
6
7
#include <stdio.h>
main()
{
    char ch[]="uvwxyz",*pc;
    pc=ch;
    printf("%c\n",*(pc+5));
}

程序运行后的输出结果是()。

共 1 分 

第27题

有以下程序(注:字符a的ASCII码值为97):

1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
main()
{
    char *s={"abc"};
    do
    {
        printf("%d",*s%10);
        ++s;
    }while(*s);
}

程序运行后的输出结果是()。

共 1 分 

第28题

有以下程序:

1
2
3
4
5
6
7
8
#include <stdio.h>
main()
{
    char s[10] = "verygood", *ps = s;
    ps += 4;
    ps = "nice";
    puts(s);
}

程序的运行结果是()。

共 1 分 

第29题

有如下程序:

1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
int disp(char *str)
{
    while(*str) putchar(*str++);
    return *str;
}
main()
{
    printf("%d\n",disp("NAME"));
}

程序运行后的输出结果是()。

共 1 分 

第30题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
int disp(char *str)
{
    while(*str) putchar(*str++);
    putchar('#');
    return *str;
}
main()
{
    printf("%d\n",disp("C##123"));
}

程序运行后的输出结果是()。

共 1 分 

第31题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
#include<stdio.h>
int fun(char *s)
{
    char *p=s;
    while(*p++!='\0');
    return(p-s);
}
main()
{
    char *p="01234";
    printf("%d\n",fun(p));
}

程序的运行结果是()。

共 1 分 

第32题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdio.h>
main()
{
    int password;
    char *p,old_str[10]="wind";
    scanf("%d",&password);
    p = old_str;
    while(*p)
    {
        printf("#%c",*p+password);
        p++;
    }
}

程序运行时,从键盘输入2<回车>,输出结果是()。

共 1 分 

第33题

有以下程序:

1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
main()
{
    char s1[]="programe",s2[]="Language";
    char *p1=s1,*p2=s2;
    int k;
    for(k=0;k<8;k++)
        if(*(p1+k)==*(p2+k))
            printf("%s ",(p1+k));
}

程序的运行结果是()。

共 1 分 

第34题

若要求从键盘读入含有空格字符的字符串,应使用函数()。

共 1 分 

第35题

设有定义:char s[81];int i=0;,以下不能将一行(不超过80个字符)带有空格的字符串正确读入的语句或语句组是()。

共 1 分 

第36题

以下选项中正确的语句组是()。

共 1 分 

第37题

以下不能将键盘输入的字符串:This is a string<回车>读入到str中的程序段是()。

共 1 分 

第38题

有定义语句:

1
char s[10];

若要从终端给s输入5个字符,错误的输入语句是()。

共 1 分 

第39题

有以下程序:

1
2
3
4
5
6
7
8
#include <stdio.h>
main()
{
    char a[30],b[30];
    scanf("%s",a);
    gets(b);
    printf("%s\n%s\n",a,b);
}

程序运行时若输入:
how are you?I am fine<回车>
则输出结果是()。

共 1 分 

第40题

有以下程序:

1
2
3
4
5
6
7
8
#include <stdio.h>
main()
{
    char a,b,c,d;
    scanf("%c%c",&a,&b);
    c=getchar();d=getchar();
    printf("%c%c%c%c\n",a,b,c,d);
}

当执行程序时,按下列方式输入数据(从第一列开始,<CR>代表回车,注意:回车是一个字符)
12<CR>
34<CR>
则输出结果是()。

共 1 分 

第41题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
char fun(char *c)
{
    if(*c<='Z'&&*c>='A')
        *c-='A'-'a';
    return *c;
}
main()
{
    char s[81],*p=s;
    gets(s);
    while(*p)
    {
        *p=fun(p);
        putchar(*p);
        p++;
    }
    printf("\n");
}

若运行时从键盘上输入OPEN THE DOOR<回车>,程序的输出结果是()。

共 1 分 

第42题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
main()
{
    char A,B,C;
    B='1';
    C='A';
    for(A=0;A<6;A++)
    {
        if(A%2)putchar(B+A);
        else putchar(C+A);
    }
}

程序运行后输出的结果是()。

共 1 分 

第43题

有如下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>
main()
{
    char *p,old_str[10]="wind";
    int password;
    scanf("%d",&password);
    p = old_str;
    while(*p)
    {
        printf("%c",*p+password);
        p++;
    }
    printf("\n");
}

程序运行时,从键盘输入2<回车>,输出结果是()。

共 1 分 

第44题

以下选项中有语法错误的是()。

共 1 分 

第45题

以下语句中存在语法错误的是()。

共 1 分 

第46题

若有定义:char*ps[]={"aa","bb","cc","dd"};,则以下叙述正确的()。

共 1 分 

第47题

若有以下程序段

1
2
3
4
char str[4][12] = {"aa","bbb","ccccc","d"},*strp[4];
int i;
for(i=0;i<4;i++)
    strp[i]=str[i];

不能正确引用字符串的选项是()。

共 1 分 

第48题

有以下程序:

1
2
3
4
5
6
#include <stdio.h>
main()
{
    char ch[3][5] = {"AAAA","BBBB","CC"};
    printf("%s\n",ch[1]);
}

程序运行后的输出结果是()。

共 1 分 

第49题

有以下程序:

1
2
3
4
5
6
7
8
9
#include <stdio.h>
main()
{
    char b[4][10];
    int i;
    for(i=0;i<4;i++)
        scanf("%s",b[i]);
    printf("%s%s%s%s\n",b[0],b[1],b[2],b[3]);
}

执行时若输入:Fig flower is red.<回车>则输出结果是()。

共 1 分 

第50题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
main()
{
    char b[3][10],c;
    int i;
    for(i=0;i<2;i++)scanf("%s",b[i]);
    i=0;
    while((c=getchar())!='\n')b[2][i++]=c;
    b[2][i] = '\0';
    printf("%s%s%s\n",b[0],b[1],b[2]);
}

执行时若输入以下字符串:
Peach flower is pink.<回车>
则输出结果是()。

共 1 分 

第51题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdio.h>
main()
{
char b[4][10],c;
int i,j;
for(i=0;i<4;i++)
{
j=0;
while((c=getchar())!=' '&& c!='\n')b[i][j++]=c;
b[i][j] = '\0';
}
printf("%s%s%s%s\n",b[0],b[1],b[2],b[3]);
}

程序运行时从第一列开始输入: Peach flower is pink.<回车>
则输出结果是()。

共 1 分 

第52题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdio.h>
#include <string.h>
main()
{
    char w[20], a[5][10] = {"abcdef""ghijkl""mnopq""rstuv""wxyz"};
    int i,j;
    for(i=0;i<5;i++)
    {
        j=0;
        while(a[i][j]!='\0')j++;
        w[i]=a[i][j-2];
    }
    w[5]='\0';
    puts(w);
}

程序运行后的输出结果是()。

共 1 分 

第53题

有以下程序:

1
2
3
4
5
6
7
#include <stdio.h>
main()
{
    char *a[]={"abcd","ef","gh","ijk"};
    int i;
    for(i=0;i<4;i++)printf("%c",*a[i]);
}

程序运行后的输出结果是()。

共 1 分 

第54题

有以下程序:

1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
#include <string.h>
main()
{
    char *mm[4]= {"abcd""1234""mnop""5678"};
    char **pm= mm;
    int i;
    for(i=0;i<4;i++) printf("%s",pm[i]+i);
    printf("\n");
}

程序的运行结果是()。

共 1 分 

第55题

有以下程序:

1
2
3
4
5
6
7
8
9
#include <stdio.h>
main()
{
    char *s[6]={"ABCD","EFGH","IJKL","MNOP","QRST","UVWX"},**p;
    int i;
    p=s;
    for(i=0;i<4;i++)printf("%s",p[i]);
    printf("\n");
}

程序运行后的输出结果是()。

共 1 分 

第56题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
main()
{
    char c[2][5]={"6938","8254"},*p[2];
    int i,j,s=0;
    for(i=0;i<2;i++)
        p[i]=c[i];
    for(i=0;i<2;i++)
        for(j=0;p[i][j]>0;j+=2)
            s=10*s+p[i][j]-'0';
    printf("%d\n",s);
}

程序运行后的输出结果是()。

共 1 分 

第57题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
void fun(char **p)
{
    ++p;
    printf("%s\n",*p);
}
main()
{
    char *a[] = {"Morning""Afternoon""Evening""Night"};
    fun(a);
}

程序的运行结果是()。

共 1 分 

第58题

以下关于字符串的叙述中正确的是()。

共 1 分 

第59题

若有定义语句char s[10]="1234567\0\0",则strlen(s)的值是()。

共 1 分 

第60题

下列选项中,能够满足“若字符串s1等于字符串s2,则执行ST”要求的是()。

共 1 分 

第61题

字符数组a和b中存储了两个字符串,判断字符串a和b是否相等,应当使用的是()。

共 1 分 

第62题

若有定义语句

1
char*s1="OK",*s2="ok";

以下选项中能够输出"OK"的语句是()。

共 1 分 

第63题

若有定义语句:

1
char str1[] = "string", str2[8], *str3, str4[10] = "string";

库函数strcpy的功能是复制字符串,以下选项中错误的函数调用是()。

共 1 分 

第64题

以下不能将s所指字符串正确复制到t所指存储空间的是()。

共 1 分 

第65题

若有以下定义和语句:

1
2
char s1[10]="abcd!", *s2="n123\\";
printf("%d%d\n"strlen(s1), strlen(s2));

则输出结果是()。

共 1 分 

第66题

以下语句的输出结果是()。

1
printf("%d\n",strlen("\t\"\065\xff\n"));
共 1 分 

第67题

有如下程序:

1
2
3
4
5
6
#include <stdio.h>
#include <string.h>
main()
{
printf("%d\n",strlen("0\t\nA011\1"));
}

程序运行后的输出结果是()。

共 1 分 

第68题

有以下程序:

1
2
3
4
5
6
7
#include<stdio.h>
#include<string.h>
main()
{
    char a[10]= "abcd";
    printf("%d,%d\n",strlen(a),sizeof(a));
}

程序运行后的输出结果是()。

共 1 分 

第69题

有以下程序:

1
2
3
4
5
6
7
#include <stdio.h>
#include <string.h>
main()
{
    char str[]={"Hello,Beijing"};
    printf("%d,%d\n",strlen(str),sizeof(str));
}

程序的运行结果是()。

共 1 分 

第70题

有以下程序:

1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
#include <string.h>
main()
{
    char x[]="STRING";
    x[0]=0;
    x[1]='\0';
    x[2]='0';
    printf("%d %d\n",sizeof(x),strlen(x));
}

程序运行后的输出结果是()。

共 1 分 

第71题

有如下程序:

1
2
3
4
5
6
7
#include <stdio.h>
#include <string.h>
main()
{
    char a[]="THIS", *b="OK";
    printf("%d,%d,%d,%d\n"strlen(a), sizeof(a), strlen(b), sizeof(b));
}

程序运行后的输出结果是()。

共 1 分 

第72题

有如下程序:

1
2
3
4
5
6
7
8
9
#include <stdio.h>
#include <string.h>
main()
{
    char name[10]="c-book";
    char *str=name;
    printf("%d,%d,%d,%d\n"sizeof(name), strlen(name), sizeof(str),
    strlen(str));
}

程序运行后的输出结果是()。

共 1 分 

第73题

有以下程序:

1
2
3
4
5
6
7
8
9
#include <stdio.h>
#include <string.h>
main()
{
    char name[9]="c##line";
    char *str=name;
    printf("%d,%d,%d,%d\n"sizeof(name), strlen(name), sizeof(str),
    strlen(str));
}

程序运行后的输出结果是()。

共 1 分 

第74题

有以下程序

1
2
3
4
5
6
7
8
#include <stdio.h>
main()
{
    char *p1 = 0;
    int *p2 = 0;
    float *p3 = 0;
    printf("%d,%d,%d\n"sizeof(p1), sizeof(p2), sizeof(p3));
}

程序运行后的输出结果是()。

共 1 分 

第75题

有以下程序(strcpy为字符串复制函数,strcat为字符串连接函数):

1
2
3
4
5
6
7
8
#include <stdio.h>
#include <string.h>
main()
{
    char a[10] = "abc",b[10] = "012",c[10] = "xyz";
    strcpy(a+1,b+2);
    puts(strcat(a,c+1));
}

程序运行后的输出结果是()。

共 1 分 

第76题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>
#include <string.h>
main()
{
    char a[20]="ab",b[20]="cdef";
    int k=0;
    strcat(a,b);
    while(a[k]!='\0')
    {
        b[k]=a[k];
        k++;
    }
    puts(b);
}

程序的运行结果是()。

共 1 分 

第77题

有以下程序(其中的strstr()函数头部格式为:char *strstr(char*p1,char *p2)确定p2字符串是否在p1中出现,并返回p2第一次出现的字符串首地址):

1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
#include <string.h>
char *a="you";
char *b="Welcome you to Beijing!";
main()
{
    char *p;
    p=strstr(b,a)+strlen(a)+1;
    printf("%s\n",p);
}

程序的运行结果是()。

共 1 分 

第78题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
#include <string.h>
char *a="you";
char *b="Welcome you to Beijing!";
main()
{
    char *p;
    p=b;
    while(*p != *a)p++;
    p+=strlen(a)+1;
    printf("%s\n",p);
}

程序运行后的输出结果是()。

共 1 分 

第79题

有以下程序:

1
2
3
4
5
6
7
#include <stdio.h>
#include <string.h>
main()
{
    char s[]="Beijing";
    printf("%d\n",strlen(strcpy(s,"China")));
}

程序运行后的输出结果是()。

共 1 分 

第80题

有以下程序:

1
2
3
4
5
6
7
8
9
10
#include<stdio.h>
#include<string.h>
main()
{
char w[20],a[5][10]={"abcdef","ghijkl","mnopq","rstuv","wxyz."};
int i;
for(i=0;i<5;i++)w[i]=a[i][strlen(a[i])-1];
w[5]='\0';
puts(w);
}

程序的运行结果是()。

共 1 分 

第81题

有以下函数:

1
2
3
4
5
6
7
8
9
10
int fun(char *x,char *y)
{
    int n=0;
    while((*x==*y)&&*x!='\0')
    {
    x++;
    y++:
    n++;
    }
}

函数的功能是()。

共 1 分 

第82题

有以下函数:

1
2
3
4
5
6
7
8
int fun(char *ps)
{
    char *p;
    p=ps;
    if(*ps==NULL)return 0;
    while(*++p);
    return(p-ps);
}

该函数的功能是()。

共 1 分 

第83题

有以下函数

1
2
3
4
5
6
7
int aaa(char *s)
{
char *t=s;
while(*t++);
t--;
return (t-s);
}

以下关于aaa函数功能叙述正确的是()。

共 1 分 

第84题

有以下函数

1
2
3
4
5
6
int fun(char *s)
{
    char *t=s;
    while(*t++);
    return(t-s);
}

该函数的功能是()。

共 1 分 

第85题

有以下函数:

1
2
3
4
void fun(char*p,char*q)
{
    while((*p++=*q++)!='\0');
}

该函数的功能是()。

共 1 分 

第86题

下列函数的功能是()。

1
2
3
4
5
6
7
8
fun(char * a,char * b)
{
    while((*b= *a)!='\0')
    {
        a++;
        b++;
    }
}
共 2 分 

第87题

有以下函数:

1
2
3
4
5
int fun(char *s,char *t)
{
    while((*s)&&(*t)&&(*t++==*s++));
    return (*s-*t);
}

函数的功能是()。

共 2 分 

第88题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>
#include <string.h>
main()
{
    int i;
    char a[]="How are you!";
    for(i=0;a[i];i++)
    {
        if(a[i]==' ')
        {
            strcpy(a,&a[i+1]);
            i=0;
        }
    }
    printf("%s\n",a);
}

程序的运行结果是()。

共 2 分 

第89题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdio.h>
#include <string.h>
main()
{
    char a[5][10]= {"china""beijing""you""tiananmen""welcome"};
    int i,j;
    char t[10];
    for(i=0;i<4;i++)
        for(j=i+1;j<5;j++)
            if(strcmp(a[i],a[j])>0)
            {
                strcpy(t,a[i]);
                strcpy(a[i],a[j]);
                strcpy(a[j],t);
            }
    puts(a[3]);
}

程序运行后的输出结果是()。

共 2 分 

第90题

有以下程序(strcat函数用以连接两个字符串):

1
2
3
4
5
6
7
8
#include <stdio.h>
#include <string.h>
main()
{
    char a[20]="ABCD\0EFG\0", b[]="IJK";
    strcat(a,b);
    printf("%s\n",a);
}

程序运行后的输出结果是()。

共 2 分 

第91题

有以下程序(程序中库函数islower(ch)用以判断ch中的字符是否为小写字母):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdio.h>
#include <ctype.h>
void fun(char *p)
{
    int i=0;
    while(p[i])
    {
        if(p[i]==' '&&islower(p[i-1]))p[i-1]=p[i-1]-'a'+'A';
        i++;
    }
}
main()
{
    char s1[100]="ab cd EFG!";
    fun(s1);
    printf("%s\n",s1);
}

程序运行后的输出结果是( )。

共 1 分 

第92题

有以下程序:

1
2
3
4
5
6
7
8
#include <stdio.h>
#include <string.h>
main()
{
    char str[][20]={"One*World","One*Dream!"}, *p=str[1];
    printf("%d,",strlen(p));
    printf("%s\n",p);
}

程序运行后的输出结果是()。

共 2 分 

第93题

有以下程序

1
2
3
4
5
6
7
8
9
#include <stdio.h>
#include <string.h>
main()
{
    char p[20]= {'a','b','c','d'}, q[]="abc", r[]="abcde";
    strcat(p,r);
    strcpy(p+strlen(q),q);
    printf("%d\n",strlen(p));
}

程序运行后的输出结果是()。

共 1 分