What happens to the memory allocation when you define variables inside a union?

  • Variables are allocated separate memory locations
  • Variables are automatically allocated on the heap
  • Variables are stored in a separate file
  • Variables share the same memory location
Variables defined inside a union share the same memory location, so only one variable's value is stored at any given time. Changing the value of one variable affects others in the union.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *