【发布时间】:2012-12-15 10:47:51
【问题描述】:
这应该在我的项目目录中创建一个名为“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;
}
【问题讨论】:
-
你真的需要学习如何使用调试器。