int strlen(char* s) { int ret = 0; while(*s != 0) { ret++; *s++; } return ret; } char* strcpy(char* dest, char* src) { char* ret = dest; while(*dest++ = *src++); return ret; } char* strcat(char* dest, char* src) { char* ret = dest;//先获取指针地址 while(*dest != 0) { dest++; } while(*dest++ = *src++); return ret; } //一样返回0,不一样返回1 int strcmp(char* s1, char* s2) { int ret = 0; while(*s1 != *s2) { ret = 1; break; } return ret; }
时间: 2024-10-26 20:48:54