更多"以下函数 fun 的功能是返回 str 所指字符串中以形参 c 中字符"的相关试题:
[填空题]以下函数fun的功能是返回str所指字符串中以形参c中字符开头的后续字符串的首地址,例如:str所指字符串为:Hello!,c中的字符为e,则函数返回字符串:ello!的首地址。若str所指字符串为空串或不包含c中的字符,则函数返回NULL。请填空。
char*fun(char *str,char c)
int n=0; char *p=str;
if(p!=NULL)
while(p[n]!=c&&p[n]!=’/o’)n++;
if(p[n]==’/0’) return NULL;
return( p+______);
[填空题]以下函数 fun 的功能是返回 str 所指字符串中以形参 c 中字符开头的后续字符串的首 地址,例如:str 所指字符串为:Hello!,c 中的字符为 e,则函数返回字符串:ello!的首地址。若 str 所指字符串为空串或不包含 c 中的字符,则函数返回 NULL。请填空。
char *fun(char *str, char c)
{ int n=0;char *p=str;
if(p!=NULL)
while(p[n]!=c&&p[n]!= ’’/0’’) n++;
if(p[n]== ’’/0’’) return NULL;
return( _________);
}
[填空题]以下函数fun的功能是返回str所指字符中中以形参c中字符开头的后续字符串的首地址,例如:str所指字符串为“Hello!”,c中的字符为’e’,则函数返回字符串"ello!"的首地址。若 str所指字符串为空中或不包含c中的字符,则函数返回NULL。请填空。
char *fun (char *str,char c)
int n=0;char*p=str;
if(p!=NULL)
while(P[n]! =c&&p[n]! =’/0’)n++;
if(p[n]==’/0’)retum NULL;
return( 【8】 );
[简答题]函数fun( )的功能是:统计substr所指子字符串在str所指字符串中出现的次数。例如,若字符串为aaas 1kaaas,子字符串为as,则应输出2。
#include<stdio.h>
int fun(char*str,char*substr)
int i,j,k,num=0;
/**********found**********/
for(i=0,str[i],i++)
for(j=i,k=0;substr[k]==str[j];k++,j++)
/**********found**********/
If(substr[k+1]==’/0’)
num++;
break;
return num;
main( )
char str[80],substr[80];
printf("Input a string:");
gets(str);
printf("Input a substring:");
gets(substr);
printf("%d/n",fun(str,substr));
[填空题]下列给定程序中函数fun的功能是:统计substr所指的字符串在str所指的字符串中出现的次数。
例如,若字符串为aaas 1kaaas,子字符串为as,则应输出2。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
int fun(char*str,char*substr)
int i,j,k,num=0;
/*********found*********/
for(i=0,str[i],i++)
for(j=i,k=0;
substr[k]==str[j];
k++,j++)
/*********found*********/
If(substr[k+1]==’/0’)
num ++;
break;
return num;
main( )
char str[80],substr[80];
printf("Input a string:");
gets(str);
printf("Input a substring:");
gets(substr);
printf("%d/n".fun(str,substr));
[填空题]以下函数 sstrcat( )的功能是实现字符串的连接,即将 t 所指字符串复制到 s 所指 字符串的尾部。例如:s 所指字符串为 abcd,t 所指字符串为 efgh,函数调用后
s 所指字符串为 abcdefgh。请填空。
#include
void sstrcat(char *s,char *t)
{ int n;
n=strlen(s);
while(*(s+n)=_________){s++; t++;}
}
[填空题]请补充函数fun( ),该函数的功能是:把从主函数中输入的字符串str2接在字符串str1的后面。
例如:str1=“How do”,str2=“you do”,结果输出:How do you do
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define N 40
void fun(char *str1,char *str2)
int i=0;
char *p1=str1;
char *p2=str2;
while( 【1】 )
i++;
for( ; 【2】 ;i++)
*(p1+i)= 【3】 ;
*(p1+i)=’/0’;
main( )
char str1[N],str2[N);
clrscr( );
printf("*****Input the string str1 & str2*****/n");
printf("/nstr1:");
gets(str1);
printf("/nstr2:");
gets(str2);
printf("**The string str1 & str2**/n");
puts(str1);
puts(str2);
fun(str1,str2);
printf("*****The new string *****/n");
puts(str1);