#include<stdio.h> #include<stdlib.h> #include<string.h> #include<assert.h> void my_strcpy(char*dest, const char*src) { assert(dest != NULL); assert(src); char*ret = dest; while (*dest++ = *src++) { ; } return ret; } int main() { char *p = "hello bit"; char arr[10] = { 0 }; my_strcpy(arr, p); printf("%s\n",arr); system("pause"); return 0; }
结果:
hello bit
请按任意键继续. . .
时间: 2024-10-11 09:07:30