<span style="font-size:18px;">//实现字符串操作函数strcpy #include<stdio.h> #include<assert.h> char *my_strcpy(char *dest, const char *src) { char *ret = dest; assert((dest != NULL) && (src != NULL));//断言 if(dest == src) return dest; while(*dest++ = *src++) { NULL; } return ret; } int main() { char p[] = "abcdef"; char q[] = "abcd"; printf("%s\n",q); return 0; }</span>
时间: 2024-12-08 01:08:46