[ create a new paste ] login | about

Link: http://codepad.org/fYMt6DlJ    [ raw code | output | fork ]

C, pasted on Apr 15:
#include <stdio.h>
  
int subst(char *str, char c1, char c2){

  while(*str){
    if(*str == c1){
      *str = c2;
    }
    str++;
  }

  return *str;
}

main(){

  char str[100];
  char s1[10], s2[10];

  printf("文字を入力してください:");
  scanf("%s", str);

  printf("変換する文字を入力してください:");
  scanf("%s", s1);
  printf("何に変換しますか:");
  scanf("%s", s2);

  printf("変換後の文字列は%sです。\n", subst(str, s1[0], s2[0]));

  return 0;
}


Output:
1
文字を入力してください:変換する文字を入力してください:何に変換しますか:変換後の文字列は(null)です。


Create a new paste based on this one


Comments: