A question about struct:
Let's take A look at the Declaration of this struct and record it as
Struct node {int a; float B; struct node * next;} s;
And the following struct declaration, record it as B
Struct node {int a; float B; struct node next;} s;
What are their differences?
I learned chapter 3 of "C and pointer" today. I have never paid attention to this problem before. Now I have a deep understanding of the statements and definitions.
The Declaration is to tell the compiler about the size of the cookies made by the cookie server. However, the cookie server is not the cookie itself, but the cookie itself!
The struct declaration in B is incorrect because the compiler considers that an undefined identifier is used in the Code statement: struct node next, because the struct of struct node has not been declared as successful yet. Why? The Declaration is to tell the compiler how much space you should reserve for this variable. At this time, the size of the struct node struct is unknown, and the cookie server is not complete. Of course, the cookie cannot be used!
Struct node * In A is A pointer type. We know that the pointer type is 4 bytes on 32-bit windows machines. Therefore, when the compiler analyzes the code: struct node * next, you can know that the next variable is four bytes to complete the Declaration.
You will find that the next type can be correctly compiled for any struct pointer, for example, struct unknown * next. At this time, although struct unknown is not declared, it is also correct because, the compiler does not care about the specific labels at this time. I only care about my work, that is, allocating memory!