#include<stdio.h>
#include<math.h>
#include<stdlib.h>
typedef struct{
int id; //食品编号
char name[100]; //食品名称
int tem_a; // 温度系数a
double tem_b; //温度系数b
int now_temperature; //当前温度
double v; //变质速率
double state; //变质状态
double day; //保质期
}food;
food foods[4]; //四个食品数据
int n;
void init(){
printf(" ===========食品管理========== \n");
printf("1.查看食品信息\n");
printf("2.排序食品保质期\n");
printf("3.更新食品信息\n");
printf("选择业务======\n");
scanf("%d",&n);
}
//从文件里读出数据到内存中
void FromFile(){
FILE * p = NULL;
p = fopen("food.dat","rb");
int i;
for(i = 0 ; i < 4 ; i++)fread(&foods[i],sizeof(food),1,p);
fclose(p);
}
//输入数据并保存到文件中
void ToFile(){
FILE * p = NULL;
p = fopen(<
食品管理系统
最新推荐文章于 2024-04-19 23:19:32 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)