早教吧作业答案频道 -->其他-->
究竟错在哪了?#includemain(){\x05FILE*p,*q;\x05inti,c[10]={1,2,3,4,5,6,7,8,9,10};\x05p=fopen("1.c","wb");\x05for(i=0;i=0)\x05{\x05\x05fputc(fgetc(p),q);\x05\x05fseek(p,-2,1);\x05}fclose(p);fclose(q);q=fopen("2.c","rb");\x05rewind(q);\x05for(i=
题目详情
究竟错在哪了?
#include
main()
{
\x05FILE *p,*q;
\x05int i,c[10]={1,2,3,4,5,6,7,8,9,10};
\x05p=fopen("1.c","wb");
\x05for(i=0;i=0)
\x05{
\x05\x05fputc(fgetc(p),q);
\x05\x05fseek(p,-2,1);
\x05}
fclose(p);
fclose(q);
q=fopen("2.c","rb");
\x05rewind(q);
\x05for(i=0;i
#include
main()
{
\x05FILE *p,*q;
\x05int i,c[10]={1,2,3,4,5,6,7,8,9,10};
\x05p=fopen("1.c","wb");
\x05for(i=0;i=0)
\x05{
\x05\x05fputc(fgetc(p),q);
\x05\x05fseek(p,-2,1);
\x05}
fclose(p);
fclose(q);
q=fopen("2.c","rb");
\x05rewind(q);
\x05for(i=0;i
▼优质解答
答案和解析
问题出在
q=fopen("2.c","wb");
fseek(p,0,2);
fseek(p,-1,1);
while(ftell(p)>=0)
这几句.
fseek会把文件结束符清除掉,请看linux man page里面的一句话:
A successful call to the fseek() function clears the end-of-file indicator for
the stream and undoes any effects of the ungetc(3) function on the same stream.
所以你的while会无限循环了.
q=fopen("2.c","wb");
fseek(p,0,2);
fseek(p,-1,1);
while(ftell(p)>=0)
这几句.
fseek会把文件结束符清除掉,请看linux man page里面的一句话:
A successful call to the fseek() function clears the end-of-file indicator for
the stream and undoes any effects of the ungetc(3) function on the same stream.
所以你的while会无限循环了.
看了 究竟错在哪了?#includ...的网友还看了以下:
查看程序错误在哪clearinput"n:"tondimev(n)fori=1tonstep1s= 2020-04-26 …
已知常数a>0,向量c=(0,a),i=(1,0),经过原点O以c+λi为方向向量的直线与经过定点 2020-06-12 …
正方体的八个顶点确定的所有直线中任选一对的情况有多少种?是不是这样列式C[8,2](C[8,2]- 2020-06-14 …
如图,网格纸上小正方形的边长为1,粗实线画出的是某几何体的三视图,则该几何体的体积为()A.8+π 2020-08-01 …
8+6=3+6=i-0=6+3+2=k2-i=k2-7=kk-上=2+i-7=7+2=2+8=8+i 2020-10-30 …
下面是求1~1000内所有偶数的和的程序,把程序框图补充完整,则()A.①处为S=S+i,②处为i= 2020-11-01 …
(2i11•广州模拟)直接写出得数8.8+i.22=&nbsx;i.n×i.2=i.e-i.n=1÷ 2020-11-01 …
直接写出0面各题7得数.七0-4.2=0.03×0.6=七22÷2七2=七i×i+七8×8=2七4÷ 2020-11-01 …
关于集合和函数.1.已知A=(-2,-1)∪(1,+∞),B=﹛x|x²+ax+b≤0},A∪B=( 2020-12-08 …
关于集合和函数.1.已知A=(-2,-1)∪(1,+∞),B=﹛x|x²+ax+b≤0},A∪B=( 2020-12-08 …