资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

C语言str部分函数实现

int m_strstr(const char*dst,const char*sub)

员工经过长期磨合与沉淀,具备了协作精神,得以通过团队的力量开发出优质的产品。创新互联建站坚持“专注、创新、易用”的产品理念,因为“专注所以专业、创新互联网站所以易用所以简单”。公司专注于为企业提供成都网站设计、成都网站制作、外贸网站建设、微信公众号开发、电商网站开发,小程序定制开发,软件按需网站开发等一站式互联网企业服务。

{

if (dst == NULL || sub == NULL)

return NULL;

int d_length = strlen(dst) + 1;

int s_length = strlen(sub) + 1;

int dst_index;

int sub_index;

int j;

for (dst_index = 0; dst_index < d_length; ++dst_index)

{

sub_index = 0;

if (dst[dst_index] == sub[sub_index])

{

j = dst_index;

while (dst[j] == sub[sub_index])

{

++sub_index;

++j;

if (sub_index == (s_length - 1))

return dst_index;

}

}

}

return -1;

}

char* m_strcpy(char* dst, const char* src)

{

if (dst == NULL || src == NULL)

return NULL;

char* dst_t = dst;

while (*dst_t++ = *src++);

return dst;

}

void* m_memmove(void* dst,const void* src,int count)

{

if (dst == NULL || src == NULL)

return NULL;

char* dst_t = (char*)dst;

char* src_t = (char*)src;

int s_length = strlen(src_t) + 1;

if ((int)dst < (int)src || (int)dst >(int)src + s_length)

{

while (count--)

{

*dst_t++ = *src_t++;

}

}

else

{

while (count)

{

*(dst_t + count) = *(src_t + count);

count--;

}

}

return dst;

}

int m_strcmp(const char* dst, const char* src)

{

assert(dst == NULL);

assert(src == NULL);

while ((*dst++ == *src++)&&(*dst != '\0')&&(*src != '\0'));

return *dst - *src;

}


当前题目:C语言str部分函数实现
本文路径:http://cdkjz.cn/article/iihogs.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220