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