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结构stackNode StackNode;
相同结构stackNode StackNode
和的typedef StackNode * StackNodePtr;
相同来袭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
是该类型的实际名称。如果声明结构就是这样,程序的其余部分将不再需要与结构标签关心自己,你可以使用nxtptr,如果它是StackNode_t的。
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屋!