有什么用的typedef? [英] What is the use of typedef?
本文介绍了有什么用的typedef?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么用用C typedef关键字的?
当需要它?
What is the use of typedef keyword in C ? When is it needed?
推荐答案
的typedef
是定义什么作为的键入的。例如:
typedef struct {
int a;
int b;
} THINGY;
... 啄
定义为给定的结构。这样的话,你可以用这样的:
...defines THINGY
as the given struct. That way, you can use it like this:
THINGY t;
...而不是:
...rather than:
struct _THINGY_STRUCT {
int a;
int b;
};
struct _THINGY_STRUCT t;
...这是更详细一点。类型定义可以做一些事情的显着更清晰,特别是函数指针。
...which is a bit more verbose. typedefs can make some things dramatically clearer, specially pointers to functions.
这篇关于有什么用的typedef?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文