为什么fseek设置的值与ftell返回值不同?

程序很简单,写了一个lzw文件,然后
用fseek将指针放在第i个字节,ftell返回值i+1
但是到了第290个字节,ftell返回802.这是为什么?

首先,贴上这几个函数的返回值 man内容

The rewind() function returns no value.  Upon successful completion,  fgetpos(),  fseek(),  fsetpos()  return  0,  and  ftell()
returns the current offset.  Otherwise, -1 is returned and errno is set to indicate the error. 

另外,fseek的第三个参数,是否用对了 SEEK_SET, SEEK_CUR, SEEK_END
分别是距离开始位置、当前位置、结尾位置 的seek定位offset

你确定你每次 SEEK 是不是从当前位置开始的,而不是头部。

已经找到原因了,用fopen(“文件名”,“r”)会出现不能识别ascii码的情况,要用二进制读写fopen(“文件名”,“rb”)和fopen(“文件名”,“wb”)就好了。楼上的虽然没有答对,但是我的问题本身也不够明确。还是给分。

LZ , 文本文件读写时 不识别 ASCII码的时候 ,会跳过这个字节吗