gpt4 book ai didi

linux - lseek64() 问题

转载 作者:太空宇宙 更新时间:2023-11-04 11:28:33 25 4
gpt4 key购买 nike

在 Linux 机器上,从 lseek64() 方法中查找时出现一些时间错误。但在相同的偏移量上一段时间后,它没有给出任何错误并且工作正常。在这种情况下,lseek64() 方法返回 -1。我们有我们自己的 c 库也是。现在我们使用两个库,一个用于在磁盘上读/写,另一个用于使用我们自己的库捕获 block 更改信息。两个库会产生问题吗?

最佳答案

您可以使用 perror("Reason:");。这会让您了解问题出在哪里。

即在 lseek64() 调用之后,使用 perror()。

/* Demonstration of error handling with perror() and errno. */

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

int main()
{
FILE *fp;
char filename[80];

printf("Enter filename: ");
gets(filename);

if (( fp = fopen(filename, "r")) == NULL)
{
perror("You goofed!");
printf("errno = %d.\n", errno);
exit(1);
}
else
{
puts("File opened for reading.");
fclose(fp);
}
return 0;
}

关于linux - lseek64() 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12853650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com