Strus Summary of various declaration definitions
Detailed explanation of Struct This is easy to confused, and there is a detailed description in "C Expert Program". Unfortunately, everyone likes to ask questions, there is a way to read books, so the BBS has already resolved, explaining a clear problem. Hey, China's diligent quality is sorrow. Here is a brief explanation of Struct to save money.
/ * struct.c
* This program demonstrates all kinds of Struct. Note that all these writes can be compiled
* Author: smileonce
* Date: 2005-01-14
* /
// This way is the most important, but it can pass, the last side of the Foo is the instance of the structure.
Struct foo
{
Int foo;
} foo;
// With Typedef, the meaning is obviously different from above, pay attention to the label behind the Struct, the end of the Bar is an alias of anonymous structure.
Typedef struct
{
Int bar;
} bar;
// This kind of writing is the most useful, because its definition is a one-time, Struct1 is an instance of an anonymous Struct
Struct
{
Int aaa;
} mystruct1;
// The most common way, clearly, MY_STRUCT_TAG is the structural label, my_struct_type is the alias for struct my_struct_tag
TypedEf struct my_struct_tag
{
Int aaa;
} my_struct_type;
// The following two definitions can be used, of course, using the type of TypeDef definition is more simple.
MY_STRUCT_TYPE MYSTRUCT2; / / Define variables through the structural alias defined by TypeDef
Struct my_struct_tag mystruct3; // define variables through structural tags
Int main (int Argc, char * argv [])
{
Return 0;
}