<分区>
在下面的例子中:
typedef struct {
const char *description;
float value;
} swag;
typedef struct {
swag *swag;
const char *sequence;
} combination;
typedef struct {
combination numbers;
const char *make;
} safe;
int main()
{
swag gold = {"GOLD!", 1000000.0};
combination numbers = {&gold, "6502"};
safe s = {numbers, "RAMACON250"};
//Correct handling
printf("Result: %s \n", s.numbers.swag->description);
//Faulty handling
// printf("Result: %s \n", s.numbers.(*swag).description);
return 0;
}
为了接收“GOLD!”
,以下行是正确的
printf("Result: %s \n", s.numbers.swag->description);
但为什么以下内容不正确,因为 (*x).y
与 x->y
printf("Result: %s \n", s.numbers.(*swag).description);
我在编译过程中收到以下错误:
C:\main.c|26|error: expected identifier before '(' token|)