fork download
  1. #include <stdio.h>
  2.  
  3. int myStrcpy(char s[],char t[]){
  4. int i;
  5. for(i=0;s[i]!='\0';i++){
  6. t[i]=s[i];//tにsを代入
  7. }
  8. t[i]='\0';//tの文字列の最後に終端文字を入れる
  9. return;
  10. }
  11. int main(void) {
  12. // your code goes here
  13. char s[100];
  14. char t[100];
  15. scanf("%s",s);//入力,sは文字列なので&がいらない,文字の場合は必要
  16. int x=myStrcpy(s,t);
  17. printf("s:%s\nt:%d\n",s,x);//結果を表示,s,tにはそれぞれ同じ文字列が入る
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5312KB
stdin
abcd
stdout
s:abcd
t:0