C语言编程求助
#include<stdlib.h>#include<stdio.h>
#include<math.h>
FILE * fptr;
main()
{ int i;
char letter;
fptr=fopen("D:\\my information.txt","w+");
if(fptr==0)
{printf("An error eccurred while opening the file!\n");
exit(1);}
for(letter='A';letter<='Z';letter++)
{fputc(letter,fptr);}
puts("Just wrote the letters A through Z");
fseek(fptr,-1,SEEK_END);
printf("Here is the file backward:\n");
for(i=26;i>=1;i--)
{letter=fgetc(fptr);
fseek(fptr,-2,SEEK_CUR);
printf("The next letter is%c\n",letter);}
fclose(fptr);
return 0;
}
这个程序的结果是书写26个大写字母到文件中,然后逆序输出。为什么倒数第五行fseek里面的数字是-2而不是-1?希望有人指导。