fork(1) download
  1. #include <stdio.h>
  2.  
  3. volatile union{
  4. unsigned char Table_ALL[2];
  5. union {
  6. unsigned char Byte ;
  7. struct {
  8. unsigned char C1_1:1;
  9. unsigned char C1_2:1;
  10. unsigned char C1_3:1;
  11. unsigned char C1_4:1;
  12. unsigned char C1_5:1;
  13. unsigned char C1_6:1;
  14. unsigned char C1_7:1;
  15. unsigned char C1_8:1;
  16. }BIT;
  17. } S1_C1;
  18.  
  19. union {
  20. unsigned char Byte ;
  21. struct {
  22. unsigned char C2_1:1;
  23. unsigned char C2_2:1;
  24. unsigned char C2_3:1;
  25. unsigned char C2_4:1;
  26. unsigned char C2_5:1;
  27. unsigned char C2_6:1;
  28. unsigned char C2_7:1;
  29. unsigned char C2_8:1;
  30. }BIT;
  31. } S1_C2;
  32. }Table;
  33.  
  34.  
  35. int main(void) {
  36. // your code goes here
  37. printf("Table_ALL[0] = %d\n", Table.Table_ALL[0]);
  38. printf("Table_ALL[1] = %d\n", Table.Table_ALL[1]);
  39.  
  40. printf("Write 1 to S1_C1.Byte\n");
  41. Table.S1_C1.Byte = 1;
  42. printf("S1_C1.Byte = %d\n", Table.S1_C1.Byte);
  43. printf("S1_C2.Byte = %d\n", Table.S1_C2.Byte);
  44.  
  45. printf("Table_ALL[0] = %d\n", Table.Table_ALL[0]);
  46. printf("Table_ALL[1] = %d\n", Table.Table_ALL[1]);
  47.  
  48. printf("Write 2 to S1_C2.Byte\n");
  49. Table.S1_C2.Byte = 2;
  50. printf("S1_C1.Byte = %d\n", Table.S1_C1.Byte);
  51. printf("S1_C2.Byte = %d\n", Table.S1_C2.Byte);
  52.  
  53. printf("Table_ALL[0] = %d\n", Table.Table_ALL[0]);
  54. printf("Table_ALL[1] = %d\n", Table.Table_ALL[1]);
  55. return 0;
  56. }
  57.  
Success #stdin #stdout 0s 4408KB
stdin
Standard input is empty
stdout
Table_ALL[0] = 0
Table_ALL[1] = 0
Write 1 to S1_C1.Byte
S1_C1.Byte = 1
S1_C2.Byte = 1
Table_ALL[0] = 1
Table_ALL[1] = 0
Write 2 to S1_C2.Byte
S1_C1.Byte = 2
S1_C2.Byte = 2
Table_ALL[0] = 2
Table_ALL[1] = 0