fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5. const int ARR_SIZE = 10;
  6. const int STR_SIZE = 20;
  7.  
  8. char** strArr = malloc(ARR_SIZE * sizeof(char*));
  9. for (int i = 0; i < ARR_SIZE; ++i)
  10. strArr[i] = malloc(STR_SIZE * sizeof(char));
  11.  
  12. strArr[9] = "Hello";
  13. strArr = realloc(strArr, (ARR_SIZE + 5) * sizeof(char*));
  14. for (int i = 0; i < 5; ++i)
  15. strArr[ARR_SIZE + i] = malloc(STR_SIZE * sizeof(char));
  16.  
  17. strArr[14] = "world!";
  18.  
  19. printf("%s %s", strArr[9], strArr[14]);
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 1920KB
stdin
Standard input is empty
stdout
Hello world!