早教吧作业答案频道 -->其他-->
究竟错在哪了?#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...的网友还看了以下:
究竟错在哪了?#includemain(){\x05FILE*p,*q;\x05inti,c[10 2020-06-06 …
#includemain(){char*p[]={"BOOL","OPK","H","SP"};i 2020-07-23 …
#includemain(){chars[]="012xyz\08s34f4w2";inti,n= 2020-07-23 …
#include#includemain(){chara[]="clanguage",t;itni 2020-07-23 …
输入一个正整数m(1≤m≤6)和m阶方阵A中的元素,如果找到A中的鞍点(鞍点的元素值在该行上最大, 2020-07-23 …
下列程序运行后的输出结果是()#includemain(){inti=1,j=3printf("% 2020-07-23 …
poj水题1068#includevoidmain(void){\x05inti,j,k,n,m;\ 2020-11-01 …
这是一段超声波函数,voidtran()//超声波测量函数{\x05uchari;\x05float 2020-11-20 …
51单片机DS18b02的驱动程序求解释下,程序在下面,为什么程序中DQ=1了;再判断不是DQ肯定是 2020-12-08 …
C语言题目求助写一个函数,使给定的一个二维数组(3X3),行列互换。。运行结果错误。#include 2020-12-14 …