为什么有不明字符输出
我并没输入这样的啊
#include<stdio.h>
struct beng{
char type[12];
int num[4];
int round[3];
int press[3];
int angle[3];
}data[4];
main()
{
FILE *fp;
char ch;
int i;
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<4;i++)
{
scanf("%s%4d%3d%3d%3d",data[i].type,&data[i].num,&data[i].round,&data[i].press,&data[i].angle);
fwrite(&data[i],sizeof(struct beng),1,fp); }
rewind(fp);
printf("\ntype number state.round state.press state.angle\n");
for(i=0;i<4;i++)
{
fread(&data[i],sizeof(struct beng),1,fp);
printf("%12s%4d%4d%4d%4d\n",data[i].type,data[i].num,data[i].round,data[i].press,data[i].angle); }
fclose(fp);
getch();
}
[此贴子已经被作者于2007-7-17 15:23:54编辑过]