Re: [語法] 關於ifstream讀取檔案的字串

看板C_and_CPP (C/C++)作者 (Eyes can tell)時間16年前 (2010/06/03 10:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)

05/31 14:02,
要包含空格, 就要靠getline了吧?? 剛好換行一起抓掉@_@"
05/31 14:02
其實可以這樣寫 std::ifstream fin("1.txt", std::ios::binary); fin.unsetf(std::ios::skipws); std::string data; std::copy(std::istream_iterator<char, char>(fin), std::istream_iterator<char, char>(), std::back_inserter(data) ); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.116.188.6 ※ 編輯: Hubert 來自: 122.116.188.6 (06/03 10:33)
文章代碼(AID): #1C1nHM2D (C_and_CPP)
文章代碼(AID): #1C1nHM2D (C_and_CPP)