这是我的代码:编译C结构
#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:“初始化”:无法从“组合”转换为“赃物* ”。 但是,如果我使用gcc控制台只是打印:“黄金!”。不明白这里发生了什么。
@remyabel我正在使用Visual Studio 13开发人员命令提示符。 – 2014-09-29 06:53:48
对不起,我发布了错误编译器的链接。 – 2014-09-29 06:54:38
@remyabel任何线索为什么我得到这个错误? – 2014-09-29 06:56:13