fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void proc(char msg[]) {
  6. msg = realloc(msg, 11);
  7. strcpy(msg, "xxxxxxxxxx");
  8. printf("\nin proc ======\n%s\n", msg);
  9. }
  10.  
  11. int main() {
  12. char *msg = malloc(6);
  13. strcpy(msg, "12345");
  14. printf("Before proc\n%s", msg);
  15. proc(msg);
  16. printf("After proc\n%s\nFIM", msg);
  17. }
  18.  
  19. //https://pt.stackoverflow.com/q/251727/101
Success #stdin #stdout 0s 10320KB
stdin
Standard input is empty
stdout
Before proc
12345
in proc ======
xxxxxxxxxx
After proc
xxxxxxxxxx
FIM