fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct {
  5. int a;
  6. int b;
  7. int c;
  8. } test_t;
  9.  
  10. test_t data[] = {
  11. {.a=1, .b=2, .c=3}
  12. , {.a=10, .b=20, .c=30}
  13. , {.a=100, .b=200, .c=300}
  14. };
  15.  
  16. int main(void) {
  17. test_t *d = malloc(sizeof(test_t)*2);
  18. d[0] = data[1];
  19. d[1] = data[2];
  20. printf("%d %d %d\n", d[0].a, d[0].b, d[0].c);
  21. printf("%d %d %d\n", d[1].a, d[1].b, d[1].c);
  22. free(d);
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 2288KB
stdin
Standard input is empty
stdout
10 20 30
100 200 300