#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream testfile;
testfile.open ("test.txt");
testfile << "success!\n";
testfile.close();
return 0;
}
1)稱爲 「克++ testfile.cpp」
2)創建一個名爲 「的test.txt」
3) 「搭配chmod U + X的a.out」
4)?? ?
5)文件保持空白。簡單的C++文件開口問題
我覺得自己像一個白癡一樣失敗,因爲這應該是微不足道的東西。
但是你真的運行過a.out嗎?並且不需要創建test.txt – 2010-04-10 19:45:53
您的代碼在VS2005中的工作原理如下。 – 2010-04-10 20:06:33
你是否從它所在的相同目錄運行可執行文件? – wilhelmtell 2010-04-10 22:32:53