请问随机读写文件的问题,fseek(fp, -2, SEEK_CUR);
#include<windows.h>#include <stdio.h>
#include <stdlib.h>
FILE * fp;
int main(void)
{
char temp;
fp=fopen("letter.dat","w+");
if (!fp)
{
puts("打开文件错误");
exit(1);
}
for (int i = 'A'; i <= 'Z'; i++)
{
fputc(i,fp);
}
fseek(fp, -1, SEEK_END);
for (int i = 26; i >0; i--)
{
temp = fgetc(fp);
printf("%c", temp);
fseek(fp, -2, SEEK_CUR); //字节数为什么是-2不是-1?
}
fclose(fp);
puts("");
system("pause");
return 0;
}