[問題] 輸入string 改成輸入浮點數
int main()
{
double x = 0.222222;
string someData = "apple";
int k = 0;
while (k <= 10)
{
ofstream outFile("output.txt");
ostringstream fn;
fn << "file" << k << ".txt";
ofstream out(fn.str().c_str(), ios_base::binary);
out.write(&someData[0], someData.size());
k++;
}
}
這是一個連續創造出file0.txt, file1.txt, ... ,file10.txt 的C++程式碼
txt裡面都是"apple"字串.
我的問題是: 如果txt的內容要改成儲存浮點數, x, 請問要怎麼修改這個程式碼? 謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.189.197.194
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1434897411.A.33B.html
※ 編輯: ej001 (118.189.197.194), 06/21/2015 22:37:26
※ 編輯: ej001 (118.189.197.194), 06/21/2015 22:46:36
→
06/21 22:50, , 1F
06/21 22:50, 1F
→
06/21 22:52, , 2F
06/21 22:52, 2F
→
06/21 22:53, , 3F
06/21 22:53, 3F
推
06/21 23:04, , 4F
06/21 23:04, 4F
→
06/21 23:15, , 5F
06/21 23:15, 5F
→
06/21 23:21, , 6F
06/21 23:21, 6F
→
06/22 09:29, , 7F
06/22 09:29, 7F
→
06/22 09:30, , 8F
06/22 09:30, 8F
→
06/22 09:31, , 9F
06/22 09:31, 9F
→
06/22 09:32, , 10F
06/22 09:32, 10F
→
06/22 10:07, , 11F
06/22 10:07, 11F
→
06/22 18:56, , 12F
06/22 18:56, 12F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章