直接贴代码:
char* strcpy(char *a,char*b){//把字符串b全部拷贝到a中 assert(a != nullptr&&b != nullptr); char *p = a; while ((*p++ = *b++) != '0'); return p; } char *strncpy(char *a,char *b,int n) {//把字符串b的前n位拷贝到a中 assert(a != nullptr&&b != nullptr); char *p = a; while (n--) { if ((*p++ = *b++) == '