C Accessing Union Members

[ad_1]

C Accessing Union Members
#include 
union Job {
   float salary;
   int workerNo;
} j;

int main() {
   j.salary = 12.3;

   // when j.workerNo is assigned a value,
   // j.salary will no longer hold 12.3
   j.workerNo = 100;

   printf("Salary =
   printf("Number of workers =
   return 0;
}

[ad_2]

Please follow and like us:
Content Protection by DMCA.com