fork(1) download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. void func(const char *&s){
  6. char *result = new char[strlen(s)+1];
  7. strcpy(result, "new stuff");
  8. s = result;
  9. }
  10.  
  11. int main(){
  12. const char *str = "old stuff";
  13. func(str);
  14. std::cout << str << "\n";
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
new stuff