Labels in struct

zeljkog via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jan 31 09:04:29 PST 2015


On 31.01.15 17:04, tcak wrote:
> I do not have a big example in the end to show, but is there any way to
> put labels into struct definitions?
>
> struct CommunicationMessage{
>      char[2] signature;
>
> mainData:
>      int info1;
>      int info2;
>
> extraData:
>      ushort checksum;
>
> content:
> }
>

Members of type struct are actualy labels.

struct CommunicationMessage{
     struct Md {
         int info1;
         int info2;
     };
     struct Ed {
         ushort checksum;
     }
     struct Cnt {
     }
     char[2] signature;
     Md mainData;
     Ed extraData;
     Cnt content;
}



More information about the Digitalmars-d-learn mailing list