•  Back 
  •  C Language 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help 
  •  Show info about hypertext 
  •  View a new file 
Topic       : C-Language Documentation
Author      : John Kormylo
Version     : C.HYP 1.0
Subject     : Documentation/C-Language
Nodes       : 233
Index Size  : 6362
HCP-Version : 3
Compiled on : Atari
@charset    : atarist
@lang       : en
@default    : 
@help       : Help
@options    : +g -i -s +x +z -t4
@width      : 75
View Ref-File[ Structures ]

A structure is a block of consecutive data items of mostly different
types, referenced by member names.  For example,

  struct list {
    char *name;
    int index;
   };

where 'list' is the structure name, and 'name' and 'index' are member
names.  Now that 'struct list' is a defined data type, it can be used
in variable definitions:

  struct list card[100];

where 'card' is an array of structures.  The individual items in the
structure are referenced using the '.' and '->' Membership Operators:

  card[i].name = "John Doe."
  (card + i)->index = 1;

One can also initialize a global or static structure variable:

  static struct list dead = {"deceased", -1};

Note: All entries (except char) will be aligned to even offsets.
      sizeof( struct <name> ) will always be an even number.

See also Names, Bit Fields, Linked List and typedef.