相关疑难解决方法(0)

在Xcode上用C++创建文件

这应该在我的项目目录中创建一个名为"tuna.txt"的文件.当我运行它时,它成功编译,但是没有创建文件.我在使用xcode的mac上.我已经在我的计算机上搜索了可能已经创建的其他地方,但似乎文件根本就没有创建.关于它为什么不起作用的任何想法?

#include <iostream>
#include <fstream>
using namespace std;
int main(void){
    ofstream file;
    file.open("tuna.txt");

    file << "I love tuna and tuna loves me!\n";
    file.close();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ macos xcode file

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

标签 统计

c++ ×1

file ×1

macos ×1

xcode ×1