无满意答案,请继续回答,谢谢!!!
得到的可能不是-1,得到的是y上面有两个点,全部代码是:
#include
#include
void main()
{
char ch='a';
int i,j=0;
long head,end;
FILE * fp;
putchar('\n');
fp=fopen("D:\\1.TXT","r");
if(fp==NULL)
{
printf("can't open this file!");
exit(0);
}
ch=fgetc(fp); //这里得到的就是y上面有两个点
fseek(fp,0L,2);
end=ftell(fp);
ch=fgetc(fp);
fseek(fp,0L,0);
head=ftell(fp);
ch=fgetc(fp);
printf("head=%ld,end=%ld\n",head,end);
ch=fgetc(fp);
i=end;
while(i>0)
{
printf("i=%d",i);
i--;
ch+=4;
fseek(fp,0L,2);
fputc(ch,fp);
if(ferror(fp))
{printf("write error!!!");break;}
putchar(ch);
j++;
fseek(fp,j,0);
ch=fgetc(fp);
}
fclose(fp);
}