Friday, June 17, 2011

6.9 Bit-fields

  • A bit-field or field for short, is a set of adjacent bits within a single implementation-defined storage unit that we will call a "word"

6.8 Unions

  • A union is a variable that may hold (at different times) objects of different types and sizes, with the compiler keeping track of size and alignment requirements 
  • Unions provide a way to manipulate different kinds of data in a single area of storage, without embedding any machine-dependent information in the program
  • Syntax:


Thursday, June 16, 2011

6.7 Typedef

  • C provides a facility called typedef for creating new data type names
  • ie. typedef int Length;        (Length a synonym for int)
  • ie. typedef char *String;       (String a synonym for char * or character pointer)

6.6 Table Lookup

Tuesday, June 14, 2011

6.4 Pointers to Structures

  • Structure pointer:

6.3 Arrays of Structures

  • Structure type key, with an array keytab of structures. Each elements of the array is a structure:








  • Initialization: