#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); else if(*a&&*b==0) return 1; else if(*a==0&&*b) return-1; return 0; } int my_strcmp1(const char *str1, const char *str2) { assert((str1 != NULL) && (str2 != NULL)); int rt = 0; while ( !(rt = *(unsigned char *)str1 - *(unsigned char*)str2 ) && *str2) { str1 ++; str2 ++; } if (rt > 0) { rt = 1; } else if (rt < 0) { rt = -1; } return rt; } int my_strcmp2(unsigned char *src, unsigned char *dst) { int ret = 0 ; while( ! (ret = *src - *dst) && *dst) ++src, ++dst; if ( ret < 0 ) ret = -1 ; else if ( ret > 0 ) ret = 1 ; 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 == '