fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void replace_char(char *s) {
  5. for (int i = 0; s[i] != '\0'; i++) {
  6. if (s[i] == '1') {
  7. s[i] = 'I'; // '1' を 'I' に置き換え
  8. }
  9. }
  10. }
  11.  
  12. int main() {
  13. char s[100]; // 最大100文字の入力を想定
  14. printf("文字列を入力してください: ");
  15. scanf("%99s", s); // 文字列を入力(最大99文字)
  16.  
  17. replace_char(s); // 置き換え処理
  18. printf("修正後の文字列: %s\n", s); // 結果を表示
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 5324KB
stdin
1NFORMAT1ON
stdout
文字列を入力してください: 修正後の文字列: INFORMATION