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 to iterate over the characters in s1 and s2 arrays.
  4. The scanf function should read input into s2 array, not s1.

Here's the corrected code:

#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; }

#includestdioh void my_strcpychar s1 char s2 	int i; 	char temp=s1i; 	 s1i=s2i; 		 s2i=temp; int main 	int i; 	char s1100 char s2100; 	scanfss1; my_strcpys1s2; 	printfss1; 1------ 已启动全部重新生

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

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