fork(1) download
  1. #include <stdio.h>
  2.  
  3. volatile union{
  4. unsigned char Table_ALL[2][2];
  5. struct{
  6. struct{
  7. union {
  8. unsigned char Byte ;
  9. struct {
  10. unsigned char C1_1:1;
  11. unsigned char C1_2:1;
  12. unsigned char C1_3:1;
  13. unsigned char C1_4:1;
  14. unsigned char C1_5:1;
  15. unsigned char C1_6:1;
  16. unsigned char C1_7:1;
  17. unsigned char C1_8:1;
  18. }BIT;
  19. } S1_C1;
  20.  
  21. union {
  22. unsigned char Byte ;
  23. struct {
  24. unsigned char C2_1:1;
  25. unsigned char C2_2:1;
  26. unsigned char C2_3:1;
  27. unsigned char C2_4:1;
  28. unsigned char C2_5:1;
  29. unsigned char C2_6:1;
  30. unsigned char C2_7:1;
  31. unsigned char C2_8:1;
  32. }BIT;
  33. } S1_C2;
  34. }S1;
  35. struct{
  36. union {
  37. unsigned char Byte ;
  38. struct {
  39. unsigned char C1_1:1;
  40. unsigned char C1_2:1;
  41. unsigned char C1_3:1;
  42. unsigned char C1_4:1;
  43. unsigned char C1_5:1;
  44. unsigned char C1_6:1;
  45. unsigned char C1_7:1;
  46. unsigned char C1_8:1;
  47. }BIT;
  48. } S2_C1;
  49.  
  50. union {
  51. unsigned char Byte ;
  52. struct {
  53. unsigned char C2_1:1;
  54. unsigned char C2_2:1;
  55. unsigned char C2_3:1;
  56. unsigned char C2_4:1;
  57. unsigned char C2_5:1;
  58. unsigned char C2_6:1;
  59. unsigned char C2_7:1;
  60. unsigned char C2_8:1;
  61. }BIT;
  62. } S2_C2;
  63. }S2;
  64. }CS_ALL;
  65. }Table;
  66.  
  67.  
  68. int main(void) {
  69. // your code goes here
  70. printf("Table_ALL[0][0] = %d\n", Table.Table_ALL[0][0]);
  71. printf("Table_ALL[0][1] = %d\n", Table.Table_ALL[0][1]);
  72. printf("Table_ALL[1][0] = %d\n", Table.Table_ALL[1][0]);
  73. printf("Table_ALL[1][1] = %d\n\n", Table.Table_ALL[1][1]);
  74.  
  75. printf("Write 1 to S1.S1_C1.Byte\n");
  76. printf("Write 2 to S1.S1_C2.Byte\n");
  77. printf("Write 3 to S2.S2_C1.Byte\n");
  78. printf("Write 4 to S2.S2_C2.Byte\n\n");
  79.  
  80. Table.CS_ALL.S1.S1_C1.Byte = 1;
  81. Table.CS_ALL.S1.S1_C2.Byte = 2;
  82. Table.CS_ALL.S2.S2_C1.Byte = 3;
  83. Table.CS_ALL.S2.S2_C2.Byte = 4;
  84.  
  85. printf("S1.S1_C1.Byte = %d\n", Table.CS_ALL.S1.S1_C1.Byte);
  86. printf("S1.S1_C2.Byte = %d\n", Table.CS_ALL.S1.S1_C2.Byte);
  87. printf("S2.S2_C1.Byte = %d\n", Table.CS_ALL.S2.S2_C1.Byte);
  88. printf("S2.S2_C2.Byte = %d\n\n", Table.CS_ALL.S2.S2_C2.Byte);
  89.  
  90. printf("Table_ALL[0][0] = %d\n", Table.Table_ALL[0][0]);
  91. printf("Table_ALL[0][1] = %d\n", Table.Table_ALL[0][1]);
  92. printf("Table_ALL[1][0] = %d\n", Table.Table_ALL[1][0]);
  93. printf("Table_ALL[1][1] = %d\n\n", Table.Table_ALL[1][1]);
  94.  
  95. printf("Write 5 to S1.S1_C1.Byte\n");
  96. printf("Write 6 to S1.S1_C2.Byte\n");
  97. printf("Write 7 to S2.S2_C1.Byte\n");
  98. printf("Write 8 to S2.S2_C2.Byte\n\n");
  99.  
  100. Table.CS_ALL.S1.S1_C1.Byte = 5;
  101. Table.CS_ALL.S1.S1_C2.Byte = 6;
  102. Table.CS_ALL.S2.S2_C1.Byte = 7;
  103. Table.CS_ALL.S2.S2_C2.Byte = 8;
  104.  
  105. printf("S1.S1_C1.Byte = %d\n", Table.CS_ALL.S1.S1_C1.Byte);
  106. printf("S1.S1_C2.Byte = %d\n", Table.CS_ALL.S1.S1_C2.Byte);
  107. printf("S2.S2_C1.Byte = %d\n", Table.CS_ALL.S2.S2_C1.Byte);
  108. printf("S2.S2_C2.Byte = %d\n\n", Table.CS_ALL.S2.S2_C2.Byte);
  109.  
  110. printf("Table_ALL[0][0] = %d\n", Table.Table_ALL[0][0]);
  111. printf("Table_ALL[0][1] = %d\n", Table.Table_ALL[0][1]);
  112. printf("Table_ALL[1][0] = %d\n", Table.Table_ALL[1][0]);
  113. printf("Table_ALL[1][1] = %d\n\n", Table.Table_ALL[1][1]);
  114. return 0;
  115. }
Success #stdin #stdout 0s 4468KB
stdin
Standard input is empty
stdout
Table_ALL[0][0] = 0
Table_ALL[0][1] = 0
Table_ALL[1][0] = 0
Table_ALL[1][1] = 0

Write 1 to S1.S1_C1.Byte
Write 2 to S1.S1_C2.Byte
Write 3 to S2.S2_C1.Byte
Write 4 to S2.S2_C2.Byte

S1.S1_C1.Byte = 1
S1.S1_C2.Byte = 2
S2.S2_C1.Byte = 3
S2.S2_C2.Byte = 4

Table_ALL[0][0] = 1
Table_ALL[0][1] = 2
Table_ALL[1][0] = 3
Table_ALL[1][1] = 4

Write 5 to S1.S1_C1.Byte
Write 6 to S1.S1_C2.Byte
Write 7 to S2.S2_C1.Byte
Write 8 to S2.S2_C2.Byte

S1.S1_C1.Byte = 5
S1.S1_C2.Byte = 6
S2.S2_C1.Byte = 7
S2.S2_C2.Byte = 8

Table_ALL[0][0] = 5
Table_ALL[0][1] = 6
Table_ALL[1][0] = 7
Table_ALL[1][1] = 8