strcpy函数

发布时间 2023-05-27 21:04:45作者: wessf

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;
}