在 Mac 上找不到 ifstream' 文件

ifstream' file not found on Mac

我正在使用 Mac 并且正在学习 C++。我试图打开并读取一个文件,我写了几行代码来完成它。但是当我用 gcc 或 g++ 或 clang 编译它时,编译器失败,因为它找不到 istream 文件。有没有办法重新安装或下载默认库。谢谢

编辑:

这是代码:

#include <ifstream>

using namespace std;

int main()
{
    ifstream ligand("ligand_dataset.txt");

    if( ligand.is_open())
    {
        cout << "File ok";
    }
    else cout << "Unable to open the file";

    return 0;
}

ifstream header 替换为 fstream

#include <fstream>

int main()
{
    std::ifstream f(....);
    return 0;
}