在C程序中有如下语句:char *func(intx,int y); 它是()。A.对函数func的定义。B.对函数f
在C程序中有如下语句:char *func(intx,int y); 它是()。
A.对函数func的定义。
B.对函数func的调用。
C.对函数func的原型说明。
D.不合法的
在C程序中有如下语句:char *func(intx,int y); 它是()。
A.对函数func的定义。
B.对函数func的调用。
C.对函数func的原型说明。
D.不合法的
有两个C程序文件T18.c和myfun.c同在VC系统目录(文件夹)下,其中T18.c文件如下: include <stdio.h> include "myfun.c" main() { fun(); prinff("\n"); } myfun.c文件如下: void fun() { char s[80],c;int n=0; while((c=getchar())! :\n) s[n++] =c; n--; while (n>=0) prinff("%c" , s [n--] ); } 当编译连接通过后,运行程序T18时,输入"Thank!”,则输出结果是【 】。
A.可以用*P表示s[0]
B.s数组中元素的个数和p所指字符串长度相等
C.s和p都是指针变量
D.数组s中的内容和指针变量p中的内容相等
A.7
B.8
C.9
D.函数调用出错
有以下程序: #include<stdio.b> void fun(char c) { if(c>X)fun(c-1): printf("%C",c); } traia() { fun(z);} 程序运行后的输出结果是()
A.xyz
B.wxyz
C.xzy
D.zvx
38) 有以下程序:
#include <stdio.h>
void fun(char *t,char *s)
{ while(*t!=0) t++;
while((*t++=*s++)!=0);
}
main()
{ char ss[10]= " acc " ,aa[10]= " bbxxyy " ;
fun(ss,aa);
printf(" %s,%s\n " ,ss,aa);
}
程序运行结果是
A)accxyy,bbxxyy
B)acc, bbxxyy
C)accxxyy,bbxxyy
D) accbbxxyy,bbxxyy
(25)有以下程序(说明:字母A的ASCII码值是65)
#include <stdio.h>
void fun(char *s)
{ while(*s)
{ if(*s%2) printf("%c",*s);
s++;
}
}
main()
{ char a[]="BYTE";
fun(a); printf("\n");
}
程序运行后的输出结果是
A)BY
B)BT
C)YT
D) YE
下列给定程序中函数fun()的功能是:求出字符串中最后一次出现的子字符串的地址,通过函数值返回,在主函数中输出从此地址开始的字符串;若未找到,则函数值为NULL。例如,当字符串中的内容为abcdabfabcdx,t中的内容为ab时,输出结果应是abcdx。当字符串中的内容为abcdabfabcdx,t中的内容为abd时,则程序输出未找到的信息:Not found!
请改正程序中的错误,使它能得出正确的结果。
注意;不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include<stdio.h>
include <conio.h>
include <string.h>
char *fun(char *s,char *t)
{
char *p,*r,*a;
/*************found**************/
a=Null;
while(*s)
{ p=s;r=t;
while(*r)
/*************found**************/
if(r= =p) {r++;p++;}
else break;
if(*r=='\0') a=s;
s++;
}
return a;
}
main()
{char s[100],t[100],,*p;
clrscr();
printf("\nPlease enter string S: ");
scanf("%s",s);
printf("\nPlease enter substring t: ");
scanf("%s",t);
p=fun(S,t);
if(p) printf("\nThe result is:%s\n",p);
else printf("\nNot found!\n ");
}
#include<stdio.h>
int fun(char*s)
{char*p=s;
while(*p!='\0')p++;
return(p-s);}
main()
{printf("%d\n",fun("hello world"));
}
程序运行结果是:______
有以下程序 include<stdio.h> yoidfun(char**p) {++p;printf(%sha,*p);} main() {char*a[]=(Morning,Aftemoon,Eyening,Night); fun(a); } 程序的运行结果是
A.ffemoon
B.Morning
C.oming
D.Afternoon