试图写文件

C++ – Trying to write files

本文关键字:文件      更新时间:2023-10-16

我正在做c++的newboston教程,刚刚做了一个关于文件处理的教程。我的代码看起来和他的完全一样,但是构建失败了。我想可能是因为我用的是mac电脑,我想这可能就是问题所在。下面是我的代码:

#include <iostream>
#inlcude <fstream>
using namespace std;
int main() {
    ofstream buckyFile;
    buckyFile.open("tuna.txt");
    buckyFile << "I love tuna and tuna loves me!n";
    buckyFile.close();
}

希望你能帮忙。

正如语法高亮显示的那样,您拼错了include:

#include <fstream>

正确包含文件流并编译。这与MAC无关

#include <fstream>