typedef 结构清晰 [英] typedef struct clarity
问题描述
我对 typedef 感到困惑 谁能把它转录成正常的组合?的结构?我真的不想处理 typedef 因为它让我感到困惑
I am getting confused with typedef can anyone transcribe this to a normal composition? of structures? I really don't want to handle typedef since it's gets me confuse
struct stackNode
{
int data;
struct stackNode *nxtptr;
};
typedef struct stackNode StackNode;
typedef StackNode *StackNodePtr;
是
typedef struct stackNode StackNode;
与 struct stackNode StackNode
相同并且 typedef StackNode *StackNodePtr;
与 struck stackNode *StackNodePtr
??
typedef struct stackNode StackNode;
is the same as struct stackNode StackNode
and typedef StackNode *StackNodePtr;
is the same as struck stackNode *StackNodePtr
??
推荐答案
一种更常见的书写方式是:
A more common way to write the very same would be:
typedef struct stackNode
{
int data;
struct stackNode *nxtptr;
} StackNode_t;
其中 stackNode
是所谓的结构标记",StackNode_t
是类型的实际名称.如果你这样声明结构体,程序的其余部分就不需要关心结构体标签,你可以像使用 StackNode_t 一样使用 nxtptr.
where stackNode
is the so called "struct tag" and StackNode_t
is the actual name of the type. If you declare structs like this, the rest of the program won't need to concern itself with the struct tag, and you can use nxtptr as if it was of StackNode_t.
这篇关于typedef 结构清晰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!