【发布时间】:2011-03-15 15:32:12
【问题描述】:
我无法访问结构的成员
代码如下:
int main()
{
typedef struct tempA
{
int a;
}tempa;
typedef struct tempB
{
tempa **tA;
}tempb;
tempb.(*tA)->a =5;
printf("\n Value of a : %d",tempb.(*tA)->a);
}
我尝试使用tempb.(*tA)->a; 访问它,但出现语法错误:
error: expected identifier before ‘(’ token
访问int a 的正确语法是什么?
提前致谢
【问题讨论】:
-
您的代码包含多个错误,包括:缺少 main() 的参数列表、缺少返回(除非您使用的是 C99 编译器),更重要的是,没有名为 tempb 的变量。请发布实际编译的代码,除非问题是“为什么这段代码不能编译”。
-
我读得太快了,问题确实是“为什么不能编译”——但你仍然试图访问一个不存在的变量。