In Linux, why lseek(1.txt, 0 , SEEK_END) = 1.txt's size +1?

20 Views Asked by At

In Linux, why lseek(1.txt, 0 , SEEK_END) = (number of texts in 1.txt) + 1, (but, if file empties lseek() is 0) ??

#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
int main(int argc, char *argv[]){
    int fd;
    fd=open(argv[1], O_RDWR);
    printf("file size : %ld\n",lseek(fd, (off_t)0 ,SEEK_END));
}
0

There are 0 best solutions below