题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-12-23 05:52:20

[单项选择]以下不能将S所指字符串正确复制到t所指存储空间的是
A. while(*t=*s) t++; s++; B) for(i=0; t[i]=s[i];i++); C) do*t++=*s++; while(*s); D) for(i= 0,j=0;t[i++]=s[j++];);

更多"以下不能将S所指字符串正确复制到t所指存储空间的是"的相关试题:

[单项选择]以下不能将s所指字符串正确复制到t所指存储空间的是( )。
A. while(*t= *s)t++;s++;)
B. for(i=0;t[i]=s[i];i++);
C. do*t++=*s++;while(*s);
D. for(i=0,j=0;t[i++]=s[j++];);
[填空题]以下函数 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++;} }
[填空题]以下sstrcpy( )函数实现字符串复制,即将t所指字符串复制到s所指内存空间中,形成一个新字符串s。请填空。
void sstrcpy(char *s,char *t)
while( *s++= );
main( )
char strl[100],str2[]="abcdefgh";
sstrcpy(str1,str2);
printf("%s//n",str1);

[填空题]

以下函数sstrcat( )的功能是实现字符串的连接,即将t所指字符串复制到s所指字符串的尾部。例如:s所指字符串为abcd,t所指字符串为efgh,函数调用后s所指字符串为abcdefgh。请填空。
#include <string.h>
void sstrcat(char *s,char *t)
{int n;
n=strlen(s);
while(*(s+n)=(){s++;t++;}
}


[单项选择]s1和s2已正确定义并分别指向两个字符串。若要求:当s1所指字符串大于s2所指字符串时,执行语句S;则以下选项中正确的是( )。
A. if(sl>s2)S;
B. if(strcmp(s1,s2))S;
C. if(strcmp(s2,s1>0)S;
D. if(strcmp)(s1,s2)>0)S;
[填空题]

以下sstrcpy( )函数实现字符串复制,即将t所指字符串复制到s所指向内存空间中,形成一个新的字符串s。请填空。
  void sstrcpy(char *s,char *t)
  { while(*s++=  【15】  );}
  main(  )
  { char str1[100],str2[ ]=”abcdefgh”;
   sstrcpy(str1,str2);
   printf(“%s/n”,str1);}


[填空题]函数sstrcmp的功能是对两个字符串进行比较。当s所指字符串和t所指字符串相等时,返回值为0;当s所指字符串大于t所指字符串时,返回值大于0;当s所指字符串小于t所指字符串时,返回值小于0(功能等同于库函数strcmp)。请填空。
#include <stdio.h>
int sstrcmp(char *s,char *t)
while(*s&&*t&& *s== 【15】 )
s++;t++;
return 【16】

[填空题]

函数strcmp( )的功能是对两个字符串进行比较,当s所指字符串和t所指字符串相等时,返回值为0;
当s所指字符串大于t所指字符串时,返回值大于0;当s所指字符串小于t所指字符串时,返回值小于
  0(功能等同于库函数strcmp( ) ),请填空。
  #include <stdio.h>
  int strcmp ( chat * s, char * t)
  { while( * s && * t && * s= 【15】 
   { s++;t++; }
   return  【16】  ;
  }


[填空题]

以下函数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( )的功能是;将s所指字符串中出现的n所指字符串全部替换成t2所指字符串,所形成的新的字符串放在w所指的数组中。在此处,要求t1和t2所指字符串的长度相同。例如:当s所指字符串中所指的内容为 abcdabfab,t1所指字符串中的内容为ab,t2所指字符串中的内容为99时,结果在w所指的数组中的内容应为99cd99f99。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
#include <string.h>
/*************found**************/
int fun (char *s, char *t1, char *t2, char *w)

int i; char *p,*r,*a;
strcpy(w,s);
while (*w)
p=w; r=t1;
/*************found**************/
while (r)
if (*r= =*p) r++;p++;
else break;
if (*r= =’/0’)
a=w; r=t2;
/*************found**************/
while (*r)*a=*r;a++;r++
w+=strlen(t2);

else w++;

main( )
char s[100],t1[100],t2[100],w[100];
clrscr( );
printf("/nPlease enter string S: ");
scanf("%s",s);

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码