prasad2315
asked on
stuctures abd unions
can we use structures in unions and
unions in structures
what are the uses of doing so
unions in structures
what are the uses of doing so
I've never tried it, but I don't see why not. Both a struct and a union are a distinct data type once you declare them, so there'd be no ambiguity to the compiler (although there might be to you).
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
this topic is a bit confusing
It's pretty straightforward if you keep in mind that a struct and a union can contain any fixed length members. Since structs and unions themselves are fixed length datatypes, they can contain each other : structs can contain structs and unions (and other fixed length data types), and unions can contain structs and unions (and other fixed length datatypes).