标签: fopen

fopen() 无法在 /tmp 共享上打开文件

我有一个 C 应用程序,它偶尔无法打开存储在/tmp共享上的文件。

这是相关的代码块:

  // open file and start parsing

  notStdin = strcmp(inFile, "-");
  if (notStdin) {
     coordsIn = fopen(inFile, "r");   <----- inFile = file that I want to open
     if (coordsIn == NULL) {
        fprintf(stderr, "ERROR: Could not open coordinates file: %s\n\t%s\n", inFile, strerror(errno));
        exit(EXIT_FAILURE);
     }
  }
  else
     coordsIn = stdin;
Run Code Online (Sandbox Code Playgroud)

在八到十次试验中,我得到一个NULLFILE 指针。这是一个示例错误消息:

ERROR: Could not open coordinates file: /tmp/coordinates.txt
       File or directory does not exist
Run Code Online (Sandbox Code Playgroud)

但是,该文件/tmp/coordinates.txt确实存在,因为我可以使用headcatmore等标准实用程序打开它。 …

linux tmp fopen

1
推荐指数
1
解决办法
5560
查看次数

标签 统计

fopen ×1

linux ×1

tmp ×1