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