69,382
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
void strcpy(char *s,char *t,int n);
int main()
{
char t[]="hello";
char s[10]={0};
strcpy(s,t,2);
printf("result:%s\n",s);
system("pause");
}
void strcpy(char *s,char *t,int n)
{
int count;
count =0;
while((*s++ =*t++)&&(count <n))
count++;
*s = '\0';
}
#include <stdio.h>
void mystrcpy(char *s,char *t,int n);
char t[]="hello";
char s[6];
main()
{
mystrcpy(s,t,2);
printf("result:%s",s);
system("pause");
}
void mystrcpy(char *s,char *t,int n)
{
int count;
count =0;
while ((*s++ =*t++)&&(count <n))
count++;
}