不使用strcmp函数实现比较两个字符串的功能
来源:百度知道 编辑:UC知道 时间:2024/05/11 17:54:50
提示:找第一个不相等字符的代码可用“while(a[i]==b[i]&&a[i]!='\0') i++;”。
不要用指针做 我还没学 希望能帮帮我做 我刚学数组
不要用指针做 我还没学 希望能帮帮我做 我刚学数组
i = 0;
while((a[i] == b[i]) && (a[i] != '\0')) i++;
if (a[i] == '\0')
printf("The 2 strings are the same.");
else
printf("The 2 strings are different.");
-------------------
大概就是这样吧...
// ret > 0 a >b
// ret = 0 a == b
// ret < 0 a < b
int my_strcmp(const char a[], const char b[])
{
int i = 0;
while(a[i]==b[i]&&a[i]!='\0') i++;
return a[i]-b[i];
}
1. 编写一个strcmp函数实现两个字符串的比较:
编程实现字符串拷贝、比较功能,要求不能使用系统库函数strcpy、strcmp
php中strcmp函数是如何进行比较的?
测试strCmp函数
关于strcmp函数
编程:用自定义函数实现字符串处理函数strcat、 strcpy、strcmp、strlen和strlwr的功能?
C语言编程:用自定义函数实现字符串处理函数strcat、 strcpy、strcmp、strlen和
3、用自定义函数实现字符串处理函数strcat、 strcpy、strcmp、strlen和strlwr的功能。
c++中,用字符串比较函数strcmp比较的是什么内容
编C语言程序:用自定义函数实现字符串处理函数strcat、 strcpy、strcmp、strlen和strlwr的功能