fork(1) download
  1. #include <stdio.h>
  2.  
  3. char** text;
  4.  
  5. int main(void) {
  6. int numElements = 20000, i;
  7. // Allocate an array of char pointers
  8. text = malloc(numElements * sizeof( char *));
  9.  
  10. for( i = 0; i < numElements; i++) {
  11. // 4 for the length of the string "test", plus one additional for \0 (NULL byte)
  12. text[i] = malloc( (4 + 1) * sizeof( char));
  13. memcpy( text[i], "test\0", 5);
  14. }
  15. printf("%s\n", text[0]);
  16. printf("%s\n", text[1]);
  17. return 0;
  18. }
Success #stdin #stdout 0s 2260KB
stdin
Standard input is empty
stdout
test
test