Re: [問題] 請問以空白為依據抓字串?

看板C_and_CPP (C/C++)作者時間16年前 (2009/03/28 19:39), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《liu2007 (薯)》之銘言: : 我記得JAVA有這個功能 : 而且每當next的時候 : 它會跳過空白鍵 : 它會自動幫你抓下一個單字 : 讀入一個文字檔 : This is my book. My name is xxx. : 我想要用C++去抓每一個單字儲存到一個陣列 : 變成 : string0 = "This" : string1 = "is" : string2 = "my" : string3 = "book." : string4 = "My" : . : . : . : . : 請問C++有什麼函式可用嗎?? #include <iostream> #include <iterator> #include <string> #include <vector> #include <algorithm> vector<string> strings; copy( istream_iterator<string>(cin), istream_iterator<string>(), back_inserter(strings) ); -- 發信站: 批踢踢實業坊(ptt.cc) From: 140.112.30.49 ※ 編輯: HuangTzHuan 來自: 140.112.30.49 (03/28 19:47)

03/28 20:05, , 1F
果然會有人回這招 XD
03/28 20:05, 1F
文章代碼(AID): #19pWoDaD (C_and_CPP)
討論串 (同標題文章)
文章代碼(AID): #19pWoDaD (C_and_CPP)