#include<stdio.h>
#include<Windows.h>
#include<assert.h>
#include<string.h>
char* my_strncpy(char *p, char *str,int n)
{
assert(*p);
assert(*str);
int i = 0;
char *s = p;
while (n-- > 0)
{
*p++ = *str++;
}
*p = '\0';
return s;
}
int main()
{
char *str = "dsssahinz";
char p[32];
printf("%s\n", my_strncpy(p, str,8));
system("pause");
return 0;
}
模拟实现strncpy
最新推荐文章于 2022-10-19 16:51:48 发布