这是我的代码:
每次我使用VS开发人员控制台进行编译时,都会收到以下错误提示:错误C2440:“初始化”:无法将“组合”转换为“swag *”。 但是如果我使用gcc,控制台只会打印“GOLD!”不太明白这里发生了什么。
#include <stdio.h>
typedef struct {
const char *description;
float value;
int age;
} swag;
typedef struct {
swag *swag;
const char *sequence;
} combination;
typedef struct {
combination numbers;
const char *make;
} safe;
int main(void)
{
swag gold = { "GOLD!", 100000.0 };
combination numbers = { &gold, "6503" };
safe s = { numbers, "RAMCON" };
printf("Contents = %s\n", s.numbers.swag->description);
getchar();
return 0;
}
每次我使用VS开发人员控制台进行编译时,都会收到以下错误提示:错误C2440:“初始化”:无法将“组合”转换为“swag *”。 但是如果我使用gcc,控制台只会打印“GOLD!”不太明白这里发生了什么。