在C中使用指向未命名结构的指针? [英] The use of a pointer to an unnamed struct in C?

查看:61
本文介绍了在C中使用指向未命名结构的指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类似的东西有什么用

typedef struct
{
    int field_1;
    float field_2;
}*T;

C中?

由于structC中的数据类型,因此将存储有关T指向的数据类型的信息以及如何正确初始化声明为T var的变量var的信息.

Since a struct is a datatype in C, where the information about the datatype pointed by T is stored and how to correctly initialize a variable var that is declared as T var ?

推荐答案

T是指向该结构的指针的别名.结构本身不是类型,但T是.

T is an alias for a pointer to the structure. The structure itself is not a type, but T is.

T不会存储在任何地方,而是存储在类型的编译器内部表中.

T is not stored anywhere but in the compilers internal tables for types.

您可以像使用它

T myVariable = malloc(sizeof(*myVariable));

这篇关于在C中使用指向未命名结构的指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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