我是新手,用Dev-c++写C语言,遇到未知错误,按照书上做的。
程序代码:#include <stdio.h>
#include <conio.h>
union computerinfo
{
char name[20];
float price;
};
int main (void)
{
union computerinfo com1={7000}; //错误出现在这里。。
int type=0;
printf("组装机(输入0)或品牌机(输入1)?\n");
scanf("%d",&type);
if (type==0)
{
printf("请输入组装机的价格:\n")
scanf("%f",&com1.price);
printf("组装机的价格是:%f\n",com1.price);
}
if (type==1)
{
printf("请输入品牌机的型号:\n")
scanf("%f",&com1.name);
printf("品牌机的型号是:%s",com1.name);
}
getch();
}编译器: Default compiler执行 gcc.exe...
gcc.exe "F:\c语言\c语言教程\c工程\xxxx.c" -o "F:\c语言\c语言教程\c工程\xxxx.exe" -g3 -I"F:\c语言\编程工具\DEV-CPP\include" -L"F:\c语言\编程工具\DEV-CPP\Lib" -g3
F:\c语言\c语言教程\c工程\xxxx.c: In function `main':
F:\c语言\c语言教程\c工程\xxxx.c:10: warning: overflow in implicit constant conversion //错误提示
F:\c语言\c语言教程\c工程\xxxx.c:17: error: syntax error before "scanf"
F:\c语言\c语言教程\c工程\xxxx.c:23: error: syntax error before "scanf"
执行结束
我按照书上做的 为什么总是错误啊??求解,谢谢啦
书上的编译环境是Lcc-win32,我用的是Dev—c++ 不知是不是编译器的原因不?

在线等待。。。










嗯