#include<stdio.h> #include<string.h> #include<stdlib.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-11-16 10:43:24