fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int function(char **data) {
  5. char data_new[542] = "bar";
  6. data_new[541] = 'Z';
  7. *data = realloc(*data, 542);
  8. memcpy(*data, data_new, sizeof(data_new));
  9. return 1;
  10. }
  11.  
  12. int main(void) {
  13. char *foo = malloc(200);
  14. function(&foo);
  15. printf("%c%c%c ... %c\n", foo[0], foo[1], foo[2], foo[541]);
  16. free(foo);
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
bar ... Z