c++寫入文本文件中(帶路徑)?

#include "stdafx.h"

#include "mytime.h"

#include

#include

int _tmain(int argc, _TCHAR* argv[])

{

using namespace std;

Time coding(2,40);

Time fixing(5,55);

Time st2(6,10);

coding.Show ();

fixing.Show();

Time st = coding+fixing+st2;

ofstream fout;

fout.open("d:\test.txt"); //必須要使用//,單個/不行

//寫入的時候將覆蓋之前所有的內容

fout << st;

fout.close ();

cin.get();

return 0;

}

相關問題答案