【发布时间】:2020-01-22 01:52:48
【问题描述】:
我有一个typedef struct,但指针类型命名为*Ptype,如下所示 -
typedef struct
{
int InputIntArg1;
int InputIntArg2;
char InputCharArg1;
} *Ptype;
我想定义一个项目 (Item1) 并为其成员分配编号 (InputIntArg1 & InputIntArg2)。但是,Item1 是一个指针。是否可以不更改 typedef 命名(*Ptype)并进行正确的声明?
int main(void)
{
Ptype Item1; // <---------- How to modify this line?
Ptype Item2;
Item1.InputIntArg1 = 1;
Item1.InputIntArg2 = 7;
Item2 = &Item1;
printf("Num1 = %d \n", Item2->InputIntArg1);
}
【问题讨论】:
标签: c pointers struct typedef void-pointers