实现字符串函数,strlen(),strcpy(),strcmp(),strcat()
1 #include<stdio.h> 2 #include<stdlib.h> 3 4 int my_strlen(char *str); 5 char *my_strcpy(char *dest, char *src); 6 char *my_strcat(char *dest, char *src); 7 int my_strcmp(char *str1,char *str2); 8 9 int main() 10 { 11 char dest[32] = "chen"; 12 char src[32] = "chengha"; 13 int res; 14 //printf("strlen(%s) = %d ",str,my_strlen(str)); 15 res = my_strcmp(dest,src); 16 printf("res = %d ",res); 17 //puts(dest); 18 system("pause"); 19 return 0; 20 } 21 22 int my_strlen(char *str) 23 { 24 int len = 0; 25 while(*str != '