关于fseek的问题
请看下面的程序
#include<stdio.h>
#include<stdlib.h>
#define SIZE 40
void main(){
FILE *fp;
long offset;
char filename[20],buf[SIZE];
printf("input file name =");
scanf("%s",filename);
fp=fopen(filename,"r");
if(fp==NULL){
fprintf(stderr,"Can't open %s\n",filename);
exit(1);
}
printf("to terminate input ^D\n");
while(1){
printf("input offset=");
if(scanf("%d",&offset)==EOF)break;
fseek(fp,offset,0);
fgets(buf,SIZE,fp);
printf("%s",buf);
}
printf("\n");
fclose(fp);
}
/*
input file name =1.txt
to terminate input ^D
input offset=0
11111
input offset=1
1111
input offset=2
111
input offset=3
11
input offset=4
1
input offset=5
input offset=6
input offset=7
22222
input offset=8
2222
input offset=9
222
input offset=10
22
input offset=11
2
input offset=12
input offset=13
input offset=14
33333
input offset=^Z
Press any key to continue*/
用的文档内容如下
11111
22222
33333
44444
55555
66666
///////////////////////////////////////////////////////////////////////////
我想问的是为什么为什么当输入5和6 的时候会得到一样的结果呢?谢谢