fork download
  1. #include <stdio.h>
  2.  
  3. typedef struct {
  4. int x;
  5. int y;
  6. }msg_s;
  7.  
  8. typedef union {
  9. int data[4];
  10. msg_s a;
  11. }msg_u;
  12.  
  13. void comp(int* a1, int* a2, int size) {
  14. printf("%d\n", size);
  15. for(int i=0;i<size; i++) {
  16. printf("%d: %d %d\n",i, a1[i], a2[i]);
  17. }
  18. }
  19.  
  20. int main(void) {
  21. msg_s z = {1, 1};
  22. msg_u t = {2, 3, 4, 5};
  23. msg_u r = {11, 12, 1, 7};
  24.  
  25. comp(t.data, r.data, sizeof(t.a)/sizeof(int));
  26. r = t;
  27. printf("%d", r.data[3]);
  28.  
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
2
0: 2 11
1: 3 12
5