fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void replaceCharacter(char *str, char oldChar, char newChar) {
  5. for (int i = 0; i < strlen(str); i++) {
  6. if (str[i] == oldChar) {
  7. str[i] = newChar;
  8. }
  9. }
  10. }
  11.  
  12. int main() {
  13. char inputString[] = "1NFORMAT1ON";
  14.  
  15. // 文字を置き換える
  16. replaceCharacter(inputString, '1', 'I');
  17.  
  18. // 結果を出力
  19. printf("Result: %s\n", inputString);
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Result: INFORMATION