strcpy函数

strcpy函数

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char* mystrcpy(char* a,char* b)
{
  if(NULL==a||NULL==b)
  {
    printf("参数错误\n");
    exit(-1);
  }
  char* p=a;
  while(*p++=*b++);
  return a;
}
int main()
{
  char a[100]="xyzxyz";
  char b[200]="123321213";
  mystrcpy(a,b);
  printf("%s\n",a);
  return 0;
}

posted on 2023-05-27 20:59  wessf  阅读(46)  评论(0)    收藏  举报