在 C Issue 中打开和创建文件?

Opening and Creating files in C Issue?

所以,我在 C 中编写了一个简单的程序,它打开一个名为 prog6_input.txt 的文件并生成另一个名为 prog_output.txt 的文件。但是,下面的代码非常适合 Windows,但每当我在 Mac 上编译时就会失败。 (我还假设这在创建文件时也有同样的问题)

FILE *ptr_file = fopen("prog6_input.txt", "r");

// We Don't have a input file
if(!ptr_file) {
    perror("Error Reading Input file.\n");
    return 1;
}

错误:No Such file or directory

如以下屏幕截图所示,该文件位于同一目录中。这适用于 windows,但不适用于 Mac OSX?为什么会这样,我该如何解决?

更新:为了 vompile 我使用终端在目录中使用 make main

你应该打开一个终端,cd 到你的 Prog6 目录,运行 你的可执行文件 ./main.