#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<windows.h>
#include<assert.h>
char *Mystrncpy(char *dest, const char *src, int n)
{
char *p = dest; int i = 0;
assert(dest);
assert(src);
for (i = 0; i < n; i++)
{
*dest++ = *src++;
}
return p;
}
int main()
{
char str1[] = "asdfgh";
char str2[] = "cdewsxqaz";
Mystrncpy(str1, str2, 5);
printf("%s", str1);
system("pause");
}
注意指针的指向以及断言的使用
博客强调了在信息技术领域中,要注意指针的指向以及断言的使用,这对于程序开发和调试等工作具有重要意义。
608

被折叠的 条评论
为什么被折叠?



