- 论坛徽章:
- 0
|
本帖最后由 banbi1985 于 2011-12-28 17:10 编辑
书上说可以。
但是试验后发现没有增加。怎么回事?
#define MAX 1024
int main(void)
{
int fd;
off_t off;
char buf[MAX];
fd = open("text.txt", O_RDWR | O_CREAT, 0666);
if(-1 == fd)
{
perror("fail to open");
exit(1);
}
printf("before reading\n");
off = lseek(fd,0,SEEK_CUR);
if(-1 == off)
{
perror("fail to seek");
exit(1);
}
printf("the offset is: %d\n", off);
if(-1 == read(fd,buf,5))
{
perror("fail to read");
exit(1);
}
printf("after reading\n");
off = lseek(fd,0,SEEK_CUR);
if(-1 == off)
{
perror("fail to seek");
exit(1);
}
printf("the offset is: %d\n", off);
... |
|