My_strcmp:字符串比较
int My_strcmp(const char* arr1, const char* arr2){ assert(arr1&&arr2); while (*arr1 + *arr2 != 0) { if (*arr1 > *arr2) return 1; else if (*arr1 < *arr2) return -1; else { arr1++; arr2++; } } }
My_strcat:字符串追加
char* My_strcat(char * arr1, const char* arr2){ assert(arr1 != NULL); assert(arr2 != NULL); char* ret = arr1; while (*arr1 != '\0') arr1++; while (*arr1 = *arr2) { arr1++; arr2++; } return ret; }
My_strcpy;字符串复制
char* My_strcpy(char* arr1, char* arr2) { char* ret = arr1; do { *arr1 = *arr2; arr1++; arr2++; } while (*(arr2 - 1) != '\0'); return ret; }
My_strlen:求字符串长短
int My_strlen(const char* p){ char* tmp = p; while (*p) p++; return p - tmp; }