C字符串复制
void mystrcpy(char *from, char *to) { for(; *from != '\0'; from++, to++) { *to = *from; } *to = '\0'; return ; } void main() { char str1[]="abcd1234"; char str2[100]={0}; mystrcpy(str1, str2); printf("%s\n", str2); }
输出: abcd1234
void mystrcpy(char *from, char *to) { for(; *from != '\0'; from++, to++) { *to = *from; } *to = '\0'; return ; } void main() { char str1[]="abcd1234"; char str2[100]={0}; mystrcpy(str1, str2); printf("%s\n", str2); }
输出: abcd1234