标签:c语言 模拟实现strncat
#include <stdio.h> #include <stdlib.h> #include <assert.h> char *my_strncat(char *dest, const char *src, int len) { char *ret = dest; while (*dest) { dest++; } while (len--) { *dest = *src; dest++; src++; } *dest = ‘\0‘; return ret; } int main() { char p1[20] = "hello "; char p2[20] = "world!"; char *ret = my_strncat(p1, p2, 7); printf("%s", ret); system("pause"); return 0; }
标签:c语言 模拟实现strncat
原文地址:http://10740329.blog.51cto.com/10730329/1715686