代码中有几个错误:1.在main函数中声明s1数组后缺少分号。2. my_strcpy函数中的变量i未初始化。3. my_strcpy函数应使用循环迭代s1和s2数组中的字符。4. scanf函数应该将输入读入s2数组,而不是s1。以下是已更正的代码:#include <stdio.h> void my_strcpy(char s1[], char s2[]) { int i = 0; while (s2[i] != '\0') { char temp = s1[i]; s1[i] = s2[i]; s2[i] = temp; i++; } } int main() { int i; char s1[100], s2[100]; scanf("%s", s2); my_strcpy(s1, s2); printf("%s", s1); return 0; }

There are several errors in the code 1 Missing semicolon after declaring s1 array in main function 2 The i variable in my_strcpy function is not initialized 3 The my_strcpy function should use a loop

原文地址: http://www.cveoy.top/t/topic/bldY 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录