#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#define MAX 10
#define PAGE 1
typedef struct{ int year; int month; int day; }DATE; //结构体日期
typedef struct{ int num; //编号 char name[10]; //名称 int price; //价格 char type; //型号 DATE jinhuo_time; //进货时间}CLOTHING; //结构体服装信息
int read_file(CLOTHING clothing[]) //读取文件{ FILE*fp; int i=0; if((fp=fopen("clothing.txt","rt"))==NULL) { printf("\n\n*****库存文件不存在!请创建*****"); return 0; } while(feof(fp)!=1) { fread(&clothing[i],sizeof(CLOTHING),1,fp); if(clothing[i].num==0) break; else i++; } fclose(fp); return i;}void save_file(CLOTHING clothing[],int sum) //保存文件{ FILE *fp; int i; if((fp=fopen("clothing.txt","wb"))==NULL) { printf("打开文件错误!\n"); return; } for(i=0;i<sum;i++) if(fwrite(&clothing[i],sizeof(CLOTHING),1,fp)!=1) printf("写文件错误!\n"); fclose(fp);}