struct x_firm
{
char name[50];
double lPrice;
char EIK[14];
int day;
int month;
int year;
};
typedef struct x_firm Firm;
I 开发者_开发百科have problem with filling struct data
printf("Enter firm name:");
scanf("%50s",&firm->name);
printf("Enter firm EIK:");
scanf("%13s",&firm->EIK);
printf("Enter firm last 5 years price:");
scanf("%f",&firm->lPrice);
printf("%f\n",firm->lPrice);
printf("Enter registration date[dd.mm.yyyy]:");
scanf("%2d.%2d.%4d", &firm->day, &firm->month, &firm->year);
The problem is that the lPrice variable isn't initialize and I don't know why! Please help!
lPrice
is a double
, not a float
. Use the %lf
formatter.
scanf("%lf",&firm->lPrice);
精彩评论