Implement String Functions, strlen (), strcpy (), strcmp (), strcat ()
1#include <stdio.h>2#include <stdlib.h>3 4 intMy_strlen (Char*str);5 Char*my_strcpy (Char*dest,Char*src);6 Char*my_strcat (Char*dest,Char*src);7 intMY_STRCMP (Char*STR1,Char*str2);8 9 intMain ()Ten { One Chardest[ +] ="Chen"; A Charsrc[ +] ="Chengha"; - intRes; - //printf ("strlen (%s) =%d\n", Str,my_strlen (str)); theres =my_strcmp (DEST,SRC); -printf"res =%d\n", res); - //puts (dest); -System"Pause"); + return 0; - } + A intMy_strlen (Char*str) at { - intLen =0; - while(*str! =' /') - { -len++; -str++; in } - returnLen; to } + - Char*my_strcpy (Char*dest,Char*src) the { * Char*address =dest; $ while((*dest = *src)! =' /')Panax Notoginseng { -dest++; theSrc++; + } A returnaddress; the } + - Char*my_strcat (Char*dest,Char*src) $ { $ Char*address =dest; - while(*dest! =' /') -dest++; the while((*dest = *src)! =' /') - {Wuyidest++; theSrc++; - } Wu returnaddress; - } About $ intMY_STRCMP (Char*STR1,Char*str2) - { - for(; *str1 = = *str2; str1++, str2++) - if(*STR1 = =' /') A return 0; + return*STR1-*str2; the}
Implement String Functions, strlen (), strcpy (), strcmp (), strcat ()