编译正确,但运行后一闪而过,怎么回事!!
#include<stdio.h>
struct stu
{
int round[3];
int press[3];
float angle[3];
};
struct beng{
char type[12];
int num[4];
struct stu state;
}data[12],*pp,*qq;
main()
{
FILE *fp;
char ch;
char b[12];
int i;
pp=data;
if((fp=fopen("c:\\WIN-TC\\projects\\stu_list.txt","wb+"))==NULL)
{
printf("Cannot open file strike any key exit!");
getch();
exit(1);
}
printf("input the data:");
for(i=0;i<12;i++,pp++)
{ scanf("%s,%4d,%3d,%3d,%3f",pp->type,&pp->num,pp->state.round,pp->state.press,pp->state.angle);
pp=data;
fwrite(&pp,sizeof(struct beng),12,fp); }
rewind(fp);
fread(&pp,sizeof(struct beng),12,fp);
printf("\n\ntype\tnumber state.round state.press state.angle\n");
for(i=0;i<12;i++,pp++)
{printf("%s\t%7d%7d%7d%7f\n",pp->type,pp->num,pp->state.round,pp->state.press,pp->state.angle); }
fclose(fp);
}
[此贴子已经被作者于2007-7-16 11:33:29编辑过]