问:实现字符串的拷贝
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> #include <assert.h> #include <string.h> int main() { char arr1[] = "abcdef"; char arr2[] = "bit"; strcpy(arr1, arr2); printf("%s", arr1); return 0; }
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> #include <assert.h> #include <string.h> char* my_strcpy(char* dest, char* scr) { assert(dest != NULL); assert(scr != NULL); char* ret = dest; while (*dest++ = *scr++) { ; } return ret; } int main() { char arr[] = "abcdefghij"; char arr1[] = "bit"; my_strcpy(arr, arr1); printf("%s",arr); return 0; }
标签:arr,38,dest,代码,练习,char,arr1,include,scr From: https://www.cnblogs.com/ayue6/p/17792094.html