char *src="abcdexxyabdeca";
char *dest="xy";
int i,j,k;
for(int i=0;src[i] != '\0';i++)
{
for(j=i,k=0;dest[k] != '\0' && src[j]==dest[k];j++,k++)
NULL;
if(k>0 && (dest[k]=='\0'))
return i;
}
return -1;
strlen 函数实现
size_t mystrlen(const char *src)
{
const char *tmp=src;
assert(src != NULL);
for(tmp=src;*tmp != '\0';++tmp)
{
NULL;
}
return tmp-src;
}
“`