Link to home
Start Free TrialLog in
Avatar of prasad2315
prasad2315

asked on

stuctures abd unions

can we use structures in unions and
unions in structures
what are the uses of doing so
Avatar of cuziyq
cuziyq

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
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of prasad2315

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).