strcmp实现
#include<stdio.h>
#include<assert.h>
int my_strcmp(const char*a,const char*b)
{
    while(*a&&*b&&*a==*b)
        a++,b++;
    if(*a&&*b)
        return(*a-*b);
    )
        ;
    &&*b)
        ;
    ;
}
int my_strcmp1(const char *str1, const char *str2)
{
     assert((str1 != NULL) && (str2 != NULL));
     ;
     while ( !(rt = *(unsigned char *)str1 - *(unsigned char*)str2 ) &&  *str2)
     {
         str1 ++;
         str2 ++;
     }
     )
     {
         rt = ;
     }
     )
     {
         rt = -;
     }
     return rt;
}  
int my_strcmp2(unsigned char *src, unsigned char *dst)
{
         ;
        while( ! (ret = *src - *dst) && *dst)
             ++src, ++dst;
         )
              ret = - ;
         )
              ret =  ;
        return( ret );
}
int my_strcmp3(const char *dest, const char *source)
{
   assert((NULL != dest) && (NULL != source));
   while (*dest && *source && (*dest == *source))
           {
                    dest ++;
                   source ++;
           }
   return *dest - *source;
}  
int my_strcmp4(const char* s1,const char * s2)
{
      for(;*s1==*s2;s1++,s2++)
        {
            if(*s1 == '\0')
                   ;
        }
      :);
}
int main()
{
    char *s1="abc",*s2="abcd";
    int m;
    m=my_strcmp4(s1,s2);
    printf("m=%d\n",m);
}
其它:
intstrcmp(p1,p2){constchar*p1;const char *p2;{registerconstunsignedchar*s1=(constunsignedchar*)p1;registerconstunsignedchar*s2=(constunsignedchar*)p2;unsignedreg_charc1,c2;do{c1=(unsignedchar)*s1++;c2=(unsignedchar)*s2++;if(c1=='\0')returnc1-c2;}while(c1==c2);returnc1-c2;}libc_hidden_builtin_def(strcmp)strcmp实现的更多相关文章
- Uva 11732 strcmp() Anyone?
		strcmp() Anyone? Time Limit: 2000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu [Subm ... 
- Linux C 字符串函数 strlen()、strcat()、strncat()、strcmp()、strncmp()、strcpy()、strncpy() 详解
		strlen(返回字符串长度) 表头文件 #include <string.h> 定义函数 size_t strlen(const char *s); 函数说明 strlen()用来计 ... 
- strcmp
		C++ Code 123456789101112 int strcmp(const char *dest, const char *source) { assert((NULL != ... 
- strlen();  strcpy();  strcat();  strcmp()     ---笔记
		指针小知识点: int a =10; int *p=&a; int *q=p; //p中保存的是a的地址 int *q=p; //将p的值赋给q 作用是让q也指向a ... 
- Strcmp(字符串1,字符串2)函数     Sizeof &&  strlen()       Substr(a,b)
		Strcmp(字符串1,字符串2)函数 { strcmp函数是比较两个字符串的大小,返回比较的结果.一般形式是: i=strcmp(字符串,字符串); 其中,字符串1.字符串2均可为字符串常量或变量 ... 
- strcmp()&&mb_ereg_replace()&&ereg()
		主要记录两个函数,一个是strcmp(),一个是mb_ereg_replace() strcmp() php 5.3 以后字符串和数组比较会返回0 测试代码: PHP <?php $passwo ... 
- strcmp函数使用总结
		Action() { /********************************* * Author:旺仔 * object:strcmp * date:2015-12-09 * fuc:我输 ... 
- strcmp函数的使用
		Action() { /********************************* * Author:旺仔 * object:strcmp * date:2015-12-09 ... 
- c/c++面试题(3)strcat/strcmp/strlen/strcpy的实现
		1.编写一个函数实现strlen以及strcpy函数. strcpy函数. 后面的字符串拷贝到一个字符数组中,要求拷贝好的字符串在字符数组的首 地址,并且只拷贝到'\0'的位置.原型是 char* m ... 
- strcmp传入nil导致崩溃
		现象:连接电脑可以正常启动程序,不连接电脑启动程序就崩溃. 崩溃信息: BSXPCMessage received error for message: Connection invalid HW k ... 
随机推荐
- 面试题41:和为s的两个数字 || 和为s的连续正数序列
			和为s的两个数字 题目:输入一个递增排序的数组和一个数字s,在数组中查找两个数,使得它们的和正好是s.如果有多对数字的和等于s,输出任意一对即可. 有点类似于夹逼的思想 注意两个int相加的和要用lo ... 
- HDU - 4420  2013icpc长春A   函数离散化 + st表
			思路:我们定义F(x) 为以x点为起点,向后(a - b)个里面有多少个白球,虽然x的范围是LL范围内的,但是白球的 个数只有1e5, 那么我们可以把连续一段相同的离散化到一起, 对于一个确定的长度为 ... 
- JQuery实现最字体的放大缩小
			网页常常有对字体放大缩小的需求,我们不妨来看一下下面这段JQuery代码的实现. 假如在html页面代码中我们有这么一段代码: <p>啦啦啦啦啦啦啦啦啦啦</p> 那么JQue ... 
- 同步 Visual Studio Code 的设置与插件
			工具推荐:Settings Sync. 小心有坑! VS Code 没有账号系统,所以设置不能同步,在多终端使用时不是很方便. 有一款插件能做这个事情:Settings Sync - Visual S ... 
- hdu-3790最短路刷题
			title: hdu-3790最短路刷题 date: 2018-10-20 14:50:31 tags: acm 刷题 categories: ACM-最短路 概述 一道最短路的水题,,,尽量不看以前 ... 
- hdu  2275  Kiki & Little Kiki 1  水题
			题目:http://acm.hdu.edu.cn/showproblem.php?pid=2275 这个题比较简单,所以就没有测试样例提供给大家,基本把题目的样例过了就可以了 题目大意 给你一串操作, ... 
- Django的orm中get和filter的不同
			Django的orm框架对于业务复杂度不是很高的应用来说还是不错的,写起来很方面,用起来也简单.对于新手来说查询操作中最长用的两个方法get和filter有时候一不注意就会犯下一些小错误.那么今天就来 ... 
- rest framework 类 继承图
- luoguP2303 [SDOI2012]Longge的问题 化式子
			求\(\sum \limits_{i = 1}^n gcd(i, n)\) \(\sum \limits_{i = 1}^n gcd(i, n)\) \(=\sum \limits_{i = 1}^n ... 
- [BZOJ3779]重组病毒(LCT+DFS序线段树)
			同[BZOJ4817]树点涂色,只是多了换根操作,分类讨论下即可. #include<cstdio> #include<algorithm> #define lc ch[x][ ... 
