C语言试卷

第641题

有以下程序:

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

程序的运行结果是()。

第642题

有以下程序:

#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));
}

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

第643题

有如下程序:

#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));
}

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

第644题

有如下程序:

#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));
}

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

第645题

有以下程序:

#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));
}

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

第646题

有以下程序

#include <stdio.h>
main()
{
    char *p1 = 0;
    int *p2 = 0;
    float *p3 = 0;
    printf("%d,%d,%d\n", sizeof(p1), sizeof(p2), sizeof(p3));
}

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

第647题

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

#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));
}

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

第648题

有以下程序:

#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);
}

程序的运行结果是()。

第649题

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

#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);
}

程序的运行结果是()。

第650题

有以下程序:

#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);
}

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

第651题

有以下程序:

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

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

第652题

有以下程序:

#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);
}

程序的运行结果是()。

第653题

有以下函数:

int fun(char *x,char *y)
{
    int n=0;
    while((*x==*y)&&*x!='\0')
    {
    x++;
    y++:
    n++;
    }
}

函数的功能是()。

第654题

有以下函数:

int fun(char *ps)
{
    char *p;
    p=ps;
    if(*ps==NULL)return 0;
    while(*++p);
    return(p-ps);
}

该函数的功能是()。

第655题

有以下函数

int aaa(char *s)
{
char *t=s;
while(*t++);
t--;
return (t-s);
}

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

第656题

有以下函数

int fun(char *s)
{
    char *t=s;
    while(*t++);
    return(t-s);
}

该函数的功能是()。

第657题

有以下函数:

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

该函数的功能是()。

第658题

下列函数的功能是()。

fun(char * a,char * b)
{
    while((*b= *a)!='\0')
    {
        a++;
        b++;
    }
}
第659题

有以下函数:

int fun(char *s,char *t)
{
    while((*s)&&(*t)&&(*t++==*s++));
    return (*s-*t);
}

函数的功能是()。

第660题

有以下程序:

#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);
}

程序的运行结果是()。