开发者

ftell on a file descriptor?

开发者 https://www.devze.com 2023-01-10 05:57 出处:网络
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 usi

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 fi开发者_开发问答le descriptor, but I'd rather not do that.


Just use:

position = lseek(fd, 0, SEEK_CUR);
0

精彩评论

暂无评论...
验证码 换一张
取 消