#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;
}
转载于:https://blog.51cto.com/10740329/1715691