fork download
  1. #include <string.h>
  2. #include <stdio.h>
  3.  
  4. void replace_char(char str[], int n, char c)
  5. {
  6. str[n] = c;
  7. }
  8.  
  9. int main (void)
  10. {
  11. char* string = "Hello World!";
  12.  
  13. printf ("%s\n", string);
  14. replace_char(string, 10, 'a');
  15. printf ("%s\n", string);
  16.  
  17. string = strdup("Hello World!");
  18.  
  19. printf ("%s\n", string);
  20. replace_char(string, 10, 'a');
  21. printf ("%s\n", string);
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 1852KB
stdin
Standard input is empty
stdout
Hello World!
Hello World!
Hello World!
Hello Worla!