求字符串的长度
比较两个字符串的大小
将字符串s复制到字符串t中
连接字符串s和字符串t
第1题:
A.求字符串的长度
B. 比较两个字符串的大小
C. 将字符串s复制到字符串t中
D. 将字符串s续接到字符串t中
第2题:
函数sstrcmp()的功能是对两个字符串进行比较。当s所指字符串和t所指字符串相等时,返回值为0;当s所指字符串大于t所指字符串时,返回值大于0;当s所指字符串小于t所指字符串时,返回值小于0(功能等同于库函数strcmp()),请填空。#include<stdio.h>int sstrcmp(char *s,char *t){ while(*s&&*t&&*s= =){s++;t++; }return;}
第3题:
有以下函数
int fun(char *s)
{ char *t=s;
while(*t++);
return(t-s);
}
该函数的功能是
A) 比较两个字符 串 的大小
B) 计算 s 所指字符串占用内存字节的个数
C) 计算 s 所指字符串的长度
D) 将 s 所指字符串复制到字符串 t 中
第4题:
假定输入的字符串中只包含字母和*号。请编写函数 fun(),它的功能是:除了尾部的,:号之外,将字符串中其他*号全部删除。形参p已指向字符串中最后一个字母。在编写函数时,不得使用C语言的字符串函数。
例如,若字符串中的内容为****A*BC*DEF*G******,删除后,字符串中的内容应当是ABCDEFG******。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<conio. h>
include<stdio. h>
void fun(char *a, char *p)
{
}
main ( )
char s[81],*t;
printf ("Enter a string: \n ");
gets (s);
t=s;
while (*t)
t++;
t--; /*指针t指向字符串尾部* /
while (*t== '*' )
t--; /*指针t指向最后一个字母*/
fun (s, t);
printf ("The string after deleted: \n");
puts (s);
}
第5题:
下面函数的功能是()sss(s,t)char*s,*t;{ while((*s)&&(*t)&&(*t++==*s++));return(*s- * t); }
A.求字符串的长度
B.比较两个字符串的大小
C.将字符串s复制到字符串t中
D.将字符串s接续到字符串t中
第6题:
以下sstrcpy()函数实现字符串复制,即将t所指字符串复制到s所指向内存空间中,形成一个新的字符串s。请填空。void sstrcpy(char*s,char*t){while(*s++=);}main(){ char str1[100],str2[]="abcdefgh"; sstrcpy(str1,str2); printf("%s\n",strl);}
第7题:
有以下函数 int fun(char *s) { char *t=s; while(*t++); return(t-s); } 该函数的功能是
A.比较两个字符串的大小
B.计算s所指字符串占用内存字节的个数
C.计算s所指字符串的长度
D.将s所指字符串复制到字符串t中
第8题:
有以下函数
int aaa(char *s)
{ char *t=s;
while(*t++);
t--;
return(t-s);
}
以下关于 aaa 函数的功能叙述正确的是
A) 求字符串s 的长度
B) 比较两个串的大小
C) 将串s 复制到串t
D) 求字符串s 所占字节数
第9题:
第10题:
下列给定程序中,函数fun()的功能是:从s所指字符串中,找出t所指字符串的个数作为函数值返回。例如,当s所指字符串中的内容为abcdabfab,t所指字符串的内容为ab,则函数返回整数3。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构.
试题程序:
include <conio.h>
include <stdio.h>
include <string.h>
int fun (char *s, char *t)
{int n; char *p, *r;
n=0;
while(*s)
{p=s;
r=t;
while (*r)
/**************found**************/
if(*r==*p) {r++; p++}
else break;
/*************found**************/
if(r=='\0')
n++;
s++;
}
return n;
}
main()
{char s[100], t[100]; int m;
clrscr();
printf("\nPlease enter string s: ");
scanf ("%s",s);
printf("\nPlease enter substring t: ");
scanf ("%s",t);
m=fun (s,t);
printf("\nThe result is: m=%d\n", m);
}