- 论坛徽章:
- 0
|
最近在帮朋友写个程序,遇到了些困难,不知如何解决,请各位高手赐教!不胜感激!
prod定义为全局变量了,在函数void init info()中为各个成员负值。结果在输入price变量时出错,程序终止。屏幕显示 scanf:floating point formats not linked. Abnormal program termination。以下是变量的定义、声明和用于输入的函数。
struct product
{char name[10];
long int quantity;
float price;
char discount[10];
};
struct product prod[4],*pointprod[4];
void init_info() /*初始化仓库内产品信息:名称、数量(现有库存量)、单价*/
{
int i;
printf("**********initiate the information of all kinds of products in storage**********" ;
draw_border(2,7,78,25);
for(i=1;i<3;i++)
{
textcolor(GREEN);
gotoxy(2,2);
cprintf(" lease input all the information of the products:\n" ;
gotoxy(2,3);
cprintf("No. %d product",i);
gotoxy(2,5);
cprintf("Name:" ;
gotoxy(2,6);
cprintf("Quantity:" ;
gotoxy(2,7);
cprintf(" rice(per):" ;
gotoxy(2, ;
cprintf("Discount:" ;
textcolor(YELLOW);
gotoxy(9,5);
scanf("%s",prod.name); /*名称*/
gotoxy(12,6);
scanf("%ld",&prod.quantity); /*数量*/
gotoxy(14,7);
scanf("%f",&prod.price); /*单价*/
gotoxy(13, ;
scanf("%s",prod.discount); /*折扣率*/
clrscr();
}
window(1,1,80,25);
clrscr();
return;
} |
|