这应该在我的项目目录中创建一个名为“tuna.txt”的文件。当我运行它时,它编译成功,但没有创建文件。我在使用xcode的mac上。我已经在计算机上搜索了可能已经创建的其他地方,但似乎完全没有创建该文件。任何想法为什么它不起作用?在Xcode上使用C++创建文件
#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;
}
你真的需要学习如何使用调试器。 –