C++ - 实现strcmp函数
来源:互联网 发布:淘宝手写披露函 编辑:程序博客网 时间:2024/05/22 15:58
// Compare.cpp - by Chimomo#include <iostream>class String{public:static int Compare(const char* s1, const char* s2){if (s1 == NULL || s2 == NULL){if (s1 == NULL && s2 != NULL){return -*s2;}if (s1 != NULL && s2 == NULL){return *s1;}if (s1 == NULL && s2 == NULL){return 0;}}else{while (*s1 && *s2 && *s1++ == *s2++);return *s1 - *s2;}}};
// Main.cpp - by Chimomo#include <iostream>#include "Compare.cpp"using namespace std;int main(){char s1[10] = "456456789";char * s2 = NULL;cout << String::Compare(s1, s2) << endl;return 0;}// Output:/*52*/
- C/C++--strcmp函数实现
- C语言实现strcmp函数
- C/C++——strcmp函数实现
- C/C++——strcmp函数实现
- 用C实现strcpy、strcmp、strlen函数
- C 实现strcmp,strcpy,strcat函数
- C语言实现strcmp()和strcpy()函数
- 【C语言】strcmp函数的实现
- 【C语言】模拟实现strcmp函数
- C 标准库 strcmp 函数的实现
- 【C语言】模拟实现strcmp()、strncmp()函数
- 【c语言】模拟实现strcmp函数
- C语言函数strcmp
- strcmp函数实现
- strcmp函数的实现
- 实现strcmp()函数
- strcmp函数的实现
- strcmp函数的实现
- typeid与typedef
- 基于逻辑表达式的集合运算
- Stanford机器学习---第三讲. 逻辑回归和过拟合问题的解决 logistic Regression & Regularization
- 字符串练习2:输出一个子串在整串中出现的次数
- 解决ubuntu下filezilla登录ftp看不到中文目录和文件的问题
- C++ - 实现strcmp函数
- 心态和想法,是提高编程水平的关键
- 大学毕业后拉开差距的原因
- vim configure
- CMD 注释用法
- Android反编译工具及其使用
- Html.TexBoxFor()中设置日期时间格式
- 玩转Android 之 TextView常用特效
- 基于arm11处理器S3C6410内核的linux下串口通信实现