开发者

Stdin problems with structure

开发者 https://www.devze.com 2023-03-07 06:18 出处:网络
struct x_firm { char name[50]; double lPrice; char EIK[14]; int day; int month; int year; }; typedef struct x_firm Firm;
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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号