Question

Is there a way to do what ftell() does (return the current position in the file) on a raw file descriptor instead of a FILE*? I think there ought to be, since you can seek on a raw file descriptor using lseek().

I know I could use fdopen() to create a FILE* corresponding to the file descriptor, but I'd rather not do that.

Was it helpful?

Solution

Just use:

position = lseek(fd, 0, SEEK_CUR);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top