1、字符串反转 – strRev
void strRev(char *str) { assert(NULL != str);
int length=strlen(str); char *end=str+length-1; while(end > str) { *str=(*str)^(*end); *end=(*str)^(*end); *str=(*str)^(*end); end--; str++; } }
2、字符串复制 – strcpy
char *strcpy(char *strDest, const char *strStr) { assert((NULL != strDest) && (NULL != strStr)); char *Dest=strDest; while((*Dest++)=(*strStr++)) {} return strDest; }
3、字符串拼接 –strcat
char *strcat(char *strDest, const char *strStr) { assert((NULL != strDest) && (NULL != strStr)); int length=strlen(strDest); char *Dest=strDest+length; while((*Dest++)=(*strStr++)) {} return strDest; }
4、字符串比较 –strcmp
int strcmp(const char *strDest, const char *strStr) { assert((NULL != strDest) && (NULL != strStr)); while(0==(*strDest - *strStr) && *strDest ) { strDest++; strStr++; } if(*strDest > *strStr) return 1; else if(*strDest < *strStr) return -1; else return 0; }
5、字符串长度 –strlen
int strlen(const char *strStr) { assert(NULL != strStr); int length = 0; while('