fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void foo( const char ** const pointer )
  6. {
  7. const char *ptr = *pointer;
  8. while(**pointer)
  9. {
  10. printf("%c", **pointer);
  11. (*pointer)++;
  12. }
  13. printf("\n");
  14. *pointer = ptr;
  15. }
  16.  
  17. void foo1( const char *const * pointer)
  18. {
  19. while(*pointer)
  20. {
  21. printf("%s\n", *pointer++);
  22. }
  23. }
  24.  
  25.  
  26. int main(void)
  27. {
  28. char **pointer = malloc(sizeof(char *));
  29. char **pointer1 = malloc(sizeof(char *) * 4);
  30.  
  31. char strings_in_RAM_0[] = "one";
  32. char strings_in_RAM_1[] = "two";
  33. char strings_in_RAM_2[] = "three";
  34.  
  35. pointer1[0] = strings_in_RAM_0;
  36. pointer1[1] = strings_in_RAM_1;
  37. pointer1[2] = strings_in_RAM_2;
  38. pointer1[3] = NULL;
  39.  
  40. *pointer = malloc(50);
  41.  
  42. strcpy(*pointer,"Const pointer to pointer");
  43.  
  44. foo(pointer);
  45. foo1(pointer1);
  46.  
  47. free(*pointer);
  48. free(pointer);
  49. free(pointer1);
  50.  
  51. return 0;
  52. }
Success #stdin #stdout 0s 4396KB
stdin
Standard input is empty
stdout
Const pointer to pointer
one
two
three