typedef struct xxx xxx xxx difference between struct && "->" "." and the access structure variable

1、
struct // C is the keyword in the structure.
Such as:
stuct node {
int A;
.....
} A;
Node equivalent to the type of structure, the key is
in fact only stuct node C, corresponding to a data type, such as int, so only a beginner difficult, such as when a given variable,
use struct node xxx, rather than the node xxx that's the key.
struct node type is a variable structure
NOTE: definition of the structure type variables can not use the struct in c ++, for example, node xxx

2、
The typedef // custom data types.
Such as: typedef int zengshu // data type to a data type with an intuitive name instead, increased portability procedure.
Further
typedef struct node {
} A;
it is to be seen as a struct node data type (see the key), this is different from the structure type definitions on the back. And A is that
intuitive data type name when referring to the more convenient.
 
Code:
1 #include<stdio.h>
2 typedef int INT;
3 int main()
4 {
5     INT a=1;
6     int b=1;
7     printf("%d %d\n",a,b);
8 }

 

3、

 1 typedef struct Trie* TrieNode;
 2 
 3 struct Trie
 4 {
 5     int val;
 6     TrieNode Next[2];
 7     Trie()
 8     {
 9         val = 0;
10         memset(Next,NULL,sizeof(Next));
11     }
12 };
This piece of code like the one above, it took * TrieNode type structure as struct Trie
If you define a variable with TrieNode is equivalent to the definition of a struct Trie structure type pointer variable (Note: It is a pointer variable)
 
"->" is a whole, which is a pointer for pointing to the sub-structure data, sub data to take.
Put another way, if we define a structure in C language, and then declare a pointer to this structure,
we use the pointer to retrieve data structure in, you should use "->."
 
But if you define a struct Trie structure type variable, then you must visit by its members. "" (This is a decimal point)
 

Guess you like

Origin www.cnblogs.com/kongbursi-2292702937/p/11985209.html