Typedef and custom struct types.
The typedef keyword is used for customizing struct types. we all know that typedef refers to an alias. const, # define, and so on are easily obfuscated in C. The difference is not discussed in this article.
/* Define the node type of a single-chain table */
Typedef char ElemType;
Typedef struct dNode {// declare the node type of a single-chain table
ElemType data;
Struct dNode * next; // pointer field} LNode, * LinkList;
// Define the struct variable struct dNode a or LNode; the pointer struct dNode * p, LNode * p, or LinkList p defining this struct is no different./* Insert a new node at the end of the linked list and create a linked list */
Note:
Sorry, I have too many comments on the Code. Beginners just want to take notes. Please forgive me.
Foreign Words:
1. thanks to the author of <300 questions that must be known in C Language>, the problems involved in this article are described in detail on pages 222nd and 223,227 (293. if you have any questions, you can check the book again. In addition, the book has a PDF version.
2. The author of this article has the following questions. Please help me with this blog. I am very grateful for this question:
- Can the nodes of a single-chain table be of different types? For example, node 1 is written as 73, and node 2 is written as e.
- Can the node be a string? How can we define it? It seems that C does not have a string type variable. Which identifier should I use.
- (See note) I want to call this single-chain table in the future, but it is just a matter-type table. How can I define it as a matter-type table or an integer table, note that this problem is different from the first one.
3. I used this editor for the first time. This is not a habit. Is it a pitfall for the editor to automatically save the post? What is the restoration content starting to end. I tried to repeat a large part of the article at the beginning. and how can I copy two of my code blocks? How can I delete them.