ftell 文件描述符?

发布于 2024-09-12 12:04:33 字数 146 浏览 1 评论 0原文

有没有办法在原始文件描述符而不是 FILE* 上执行 ftell() 的操作(返回文件中的当前位置)?我认为应该有,因为您可以使用 lseek() 来查找原始文件描述符。

我知道我可以使用 fdopen() 创建与文件描述符相对应的 FILE*,但我不想这样做。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深陷 2024-09-19 12:04:33

只需使用:

position = lseek(fd, 0, SEEK_CUR);

Just use:

position = lseek(fd, 0, SEEK_CUR);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文