关于struct的问题? [英] question about struct??

查看:72
本文介绍了关于struct的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。我对下面的struct定义感到困惑:

typedef struct TAG

{

comments ....

} ;

我的困惑是什么:是typedef extra ??为什么我们不只是使用

struct TAG

{

评论....

};

我的问题是:它们之间有什么区别吗?

谢谢

Hi, all. I feel confuse about below struct definition:
typedef struct TAG
{
comments....
};
What my confusion is: is typedef extra??why we not just use
struct TAG
{
comments....
};
My question is: is there any difference between them?
Thanks

推荐答案

嗨...


在普通C中,当你''typedef''的时候,然后呢表现为内置

类型。

因此,如果您从上面的示例中排除''typedef''关键字,那么

会有键入


void函数(struct TAG * tagptr);


with typedef,你可以写一下


void function(TAG * tagptr);


bye :)

hi...

in plain C, when you ''typedef'' something, it then behaves as a builtin
type.
So, if you exclude the ''typedef'' keyword from your example above, you
would have to type

void function(struct TAG * tagptr);

with typedef, you can just write

void function(TAG * tagptr);

bye :)




typedef就像Linux中的alias命令。你可以自己别名(定义)一种




如果你使用typedef struct TAG {} Tag;

那么你可以这样做:

标记mystruct;

去掉一个结构;


如果你使用struct TAG {} Tag;

然后你必须这样做:

struct标签mystruct;

去掉一个结构;


它是我看到的唯一区别;


http://www.c-faq.com/struct/typedef.html

ma ****** @ ntu.edu.sg 写道:
大家好。我对下面的struct定义感到困惑:
typedef struct TAG
{
评论....

};

我的困惑是什么是:typedef extra ??为什么我们不只是使用
struct TAG
{
评论....

};

我的问题是:它们之间有什么区别吗?
谢谢
Hi, all. I feel confuse about below struct definition:
typedef struct TAG
{
comments....
};
What my confusion is: is typedef extra??why we not just use
struct TAG
{
comments....
};
My question is: is there any difference between them?
Thanks






确定。但我的观点是:

typedef struct TAG {};和struct TAG {};

(注意结构定义后面没有变量) !)。

谢谢

ok. But my point is that:
what is difference about typedef struct TAG { };and struct TAG { };
(pls take note that there is no variable behind struc definition! ).
Thanks


这篇关于关于struct的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆