fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct
  5. {
  6. int hours;
  7. int minutes;
  8. int seconds;
  9. } Time;
  10.  
  11. void time_print(Time t)
  12. {
  13. printf("Time is: %d:%d:%d\n", t.hours, t.minutes, t.seconds);
  14. }
  15.  
  16. int main(void)
  17. {
  18. Time *testTimePointers[2];
  19.  
  20. testTimePointers[0] = malloc(sizeof(Time));
  21. testTimePointers[0]->hours = 11;
  22. testTimePointers[0]->minutes = 10;
  23. testTimePointers[0]->seconds = 9;
  24.  
  25. testTimePointers[1] = malloc(sizeof(Time));
  26. testTimePointers[1]->hours = 7;
  27. testTimePointers[1]->minutes = 6;
  28. testTimePointers[1]->seconds = 5;
  29.  
  30. time_print(*(testTimePointers[0]));
  31. time_print(*(testTimePointers[1]));
  32.  
  33. printf("=============\n");
  34.  
  35.  
  36. Time **ttp_cur_p = testTimePointers;
  37. time_print(*(*ttp_cur_p));
  38. ttp_cur_p++;
  39. time_print(*(*ttp_cur_p));
  40.  
  41. free(testTimePointers[0]);
  42. free(testTimePointers[1]);
  43.  
  44. return 0;
  45. }
Success #stdin #stdout 0s 2140KB
stdin
Standard input is empty
stdout
Time is: 11:10:9
Time is: 7:6:5
=============
Time is: 11:10:9
Time is: 7:6:5