Embedded C language keyword --- 3.2 Custom Data Types

1. struct structure

  The basic syntax

  struct myabc{

        unsigned int a;

        unsigned int b;

        unsigned int c;

        unsigned int d;

        }

  transfer:

  int             i;

  struct myabc mybuf; // mybuf type is myabc

       The number of structures is associated with some packaged as a whole, easy to use. Here I am in the course of work in a very complex project, to see the most is the structure of the body.

    Its memory size and the memory occupied by its members.

 

2. union union

  The use of union with struct keyword similar. Which is a common start address.

  union myabc{

        char a ;

        int b;

        double exp;

        } 

 

3. enum enumeration (collection)

  Enumeration enum {name list of constants};

  enum week {

        Monday = 0, Tuesday = 1, Wednesday = 2, Thursday, Friday, Saturday, Sunday

        };

 

4. typedef alias data type

  int a; // a is a variable of type int

       typedef int a; // a nickname is an int

    A data type already exists an alias.

  For example

  typedef                          char         char_t;

  typedef    signed char         int8_t;

  typedef       double         float64_t;

 

Guess you like

Origin www.cnblogs.com/ivyharding/p/11094224.html