fork(54) download
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4.  
  5. int main()
  6. {
  7. char** array = malloc(1 * sizeof(*array));
  8.  
  9. if (array)
  10. {
  11. array[0] = "This";
  12.  
  13. printf("%s\n------\n", array[0]);
  14.  
  15. char** tmp = realloc(array, 2 * sizeof(*array));
  16. if (tmp)
  17. {
  18. array = tmp;
  19. array[1] = "That";
  20.  
  21. printf("%s\n", array[0]);
  22. printf("%s\n", array[1]);
  23. }
  24.  
  25. free(array);
  26. }
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0.01s 1808KB
stdin
Standard input is empty
stdout
This
------
This
That