自定义strcmp函数.
来源:百度知道 编辑:UC知道 时间:2024/09/22 12:35:52
自定义一个strcmp函数.
字符串比较
三楼的兄弟,如果是
"Abc"和"abc"比呢?
*s1=0 是赋值语句吧。
hldzhuzhu 兄弟,你的函数少一个出口.如果是两个字符串相等的话怎么处理呢?
你把函数改了,我记的上次你写的不是这个函数.
字符串比较
三楼的兄弟,如果是
"Abc"和"abc"比呢?
*s1=0 是赋值语句吧。
hldzhuzhu 兄弟,你的函数少一个出口.如果是两个字符串相等的话怎么处理呢?
你把函数改了,我记的上次你写的不是这个函数.
#include<iostream>
#include<iomanip>
using namespace std;
int strcmp( char* s1,char* s2)
{
for(;*s1==*s2 && *s1!=0;++s1,++s2);
return *s1-*s2;
}
void test( char* s1,char* s2)
{
int x=strcmp( s1,s2);
cout.width(12);
if( x>0)
cout<<setw(12)<<s1<<" > "<<setw(12)<<s2<<endl;
else if( x==0)
cout<<setw(12)<<s1<<" = "<<setw(12)<<s2<<endl;
else
cout<<setw(12)<<s1<<" < "<<setw(12)<<s2<<endl;
}
int main()
{
test( "traxex","traxex");
test( "hldzhuzhu","zhuzhu");
test( "cpp","c++");
return 0;
}
输出:
$ emacs strcpy
编程:用自定义函数实现字符串处理函数strcat、 strcpy、strcmp、strlen和strlwr的功能?
C语言编程:用自定义函数实现字符串处理函数strcat、 strcpy、strcmp、strlen和
3、用自定义函数实现字符串处理函数strcat、 strcpy、strcmp、strlen和strlwr的功能。
测试strCmp函数
关于strcmp函数
编C语言程序:用自定义函数实现字符串处理函数strcat、 strcpy、strcmp、strlen和strlwr的功能
求教C++strcmp函数的用法???
自定义函数
php中strcmp函数是如何进行比较的?
什么是用户自定义函数