C language - the structure defined in several ways

If the connection is behind the struct name, the name for its structure.
The first is the basic definition of the structure, which defines a structure A.

struct A // first 
{
    int A;
};

The second is in the definition of a structure defines a variable B, while a structure body B m.

struct B // second 
{
    int B;
}m;

The third structure is defined not give the name of the structure, but the definition of a variable of the structure n, that is to say, if you want to define a variable elsewhere in the structure does not work, only this variable n in the definition of the structure of the job while the defined variables.

struct  // third 
{
     int C;
}n;

The fourth structure is defined on the basis of a first configuration defined by typedef plus keyword, then we will struct D {int d} as a data type, but did not give as an alias, with D defined directly variable is not acceptable. D test ;, as such defined is not directly variable test. But struct D test; feasible.

typedef struct D // fourth 
{
      int D;
};

The fifth structure is defined on the basis of the structure defined on a fourth adding alias x, put in a fourth case like structure is defined as in this case the structure aliased E x, it is possible to use x definition of the structure of the variable E. E can not be directly defined by the need to add struct, struct E test as in the previous ;.

typedef struct E // fifth 
{
      int E;
}x;

The sixth structure is defined on the basis of a fifth of the structure minus the name, but if y direct use to define the structure type variables are possible. As y test ;. (Common)

typedef struct  // sixth 
{
      int F;
}Y;

Guess you like

Origin www.cnblogs.com/mhq-martin/p/12093190.html