Ad

To make Hello World return string modifiable, can always allocate memory for the string.
Here the code should produce "Xello World." when return string modified.

Code
Diff
  • char* Hi (void)
    {
      char* ans=malloc(13);
      strcpy(ans,"Hello World.");
      return ans;
    }
    
    • const char* Hi (void)
    • char* Hi (void)
    • {
    • return("Hello World.");
    • }
    • char *oopsHi(void)
    • {
    • return ("Hello World.");
    • char* ans=malloc(13);
    • strcpy(ans,"Hello World.");
    • return ans;
    • }