[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

SV: skillnaden mellan struct och union



Kære Kalle,

Kalle skrev:
---------------------------------------
>Kan någon förklara skillnaden mellan en struktur variabel och en union
>variabel?
>
>struct siffror { int a; double b; long c; }
>struct siffror tal1;
>
>union siffror { int a; double b; long c; }
>union siffror tal1;
>
>Det verkar innebära precis samma sak!? 
---------------------------------------


Der er stor forskel på en struct og en union.

I en struct laver du en brugerspecificeret datatype, og du vil få adgang
til 3 FORSKELLIGE variable (se på deres adresser). Størrelsen på en
struct er mindst summen af størrelsen af members, og ofte er der padded
bytes ind af hensyn til alignment.

I en union får du adgang til et dataområde på 3 FORSKELLIGE måder (se på
deres adresser). Størrelsen på en union er typisk lig størrelsen af den
største type.

mvh
Jan Eggert Kofoed
sslug@sslug


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:07 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *