- 論壇徽章:
- 0
|
最近在幫朋友寫個程序,遇到了些困難,不知如何解決,請各位高手賜教!不勝感激!
prod定義為全局變量了,在函數(shù)void init info()中為各個成員負值。結果在輸入price變量時出錯,程序終止。屏幕顯示 scanf:floating point formats not linked. Abnormal program termination。以下是變量的定義、聲明和用于輸入的函數(shù)。
struct product
{char name[10];
long int quantity;
float price;
char discount[10];
};
struct product prod[4],*pointprod[4];
void init_info() /*初始化倉庫內產(chǎn)品信息:名稱、數(shù)量(現(xiàn)有庫存量)、單價*/
{
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); /*數(shù)量*/
gotoxy(14,7);
scanf("%f",&prod.price); /*單價*/
gotoxy(13, ;
scanf("%s",prod.discount); /*折扣率*/
clrscr();
}
window(1,1,80,25);
clrscr();
return;
} |
|