#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
struct shop
{char a; //收款机编号
char b; //商品编号
float c; //价格
int d; //数量 } zong[100];
int count=0;/*t统计一共有几笔销售记录*/
charu()
{ FILE *fp;
printf("输入收款机编号:");
scanf("%d",&zong[count].a);
printf("输入商品编号:");
scanf("%d",&zong[count].b);
printf("输入价格:");
scanf("%f",&zong[count].c);
printf("输入数量:");
scanf("%d",&zong[count].d);
if((fp=fopen("D:\\shangping.txt","w"))==NULL)
{printf("cannot open file\n");}
if(fwrite(&zong[count],sizeof(struct shop),1,fp)!=1)
printf("file weite error\n");
count++;
fclose(fp);是这样吗? 我的目的是要把这个结构体数组写进文件中,
再读取出来,进行操作