struct x_firm
{
char name[50];
double lPrice;
char EIK[14];
int day;
int month;
int year;
};
typedef struct x_firm Firm;
Run Code Online (Sandbox Code Playgroud)
我在填充struct数据时遇到问题
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);
Run Code Online (Sandbox Code Playgroud)
问题是lPrice变量没有初始化,我不知道为什么!请帮忙!
lPrice是一个double,而不是一个float.使用%lf格式化程序.
scanf("%lf",&firm->lPrice);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
183 次 |
| 最近记录: |