strlen
int my_strlen(const char *pc)
{
int i = 0;
while (pc[i])
i++;
return i;
}
strcat
char * my_strcat(char *pc1, const char *pc2)
{
int i = 0, j = 0;
while (pc1[i])
i++;
while (pc2[j])
pc1[i++] = pc2[j++];
pc1[i] = '\0';
return pc1;
}
strcpy
char * my_strcpy(char *pc1, const char *pc2)
{
int i = 0;
while (pc2[i])
{
pc1[i] = pc2[i];
i++;
}
pc1[i] = '\0';
return pc1;
}
strcmp
int my_strcmp(const char *pc1, const char *pc2)
{
while (*pc1 == *pc2)
{
if (*pc1 == '\0')
return 0;
pc1++;
pc2++;
}
return *pc1 - *pc2;
}
strstr在下一篇哦