Re: [問題] C++ string 與 C char* 使用strtok的問題

看板C_and_CPP (C/C++)作者 (Acquire higher)時間16年前 (2010/03/02 21:51), 編輯推噓1(106)
留言7則, 3人參與, 最新討論串2/3 (看更多)
※ 引述《Aligu1009 (=.=)》之銘言: #include <sstream> #include <string> #include <iostream> int main() { // stringstream 的用途? std::istringstream sin("this is xxx"); std::string word; // 為甚麼 sin>>word 可以轉 boolean ? while(sin>>word){ std::cout<<word<<"\n"; } return 0; } 請小心服用 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.123.218.30 ※ 編輯: adxis 來自: 140.123.218.30 (03/02 21:53)

03/02 21:54, , 1F
tks,簡潔有力,不過我還是想知道我問的問題的成因
03/02 21:54, 1F

03/02 22:01, , 2F
成因在 basic_string.tcc:146 他有檢查你丟的是不是null ptr
03/02 22:01, 2F

03/02 22:03, , 3F
請問這個 exception 是標準規定要丟的嗎?
03/02 22:03, 3F

03/02 22:04, , 4F
剛剛用 VS 2008 發現它不會丟例外...?
03/02 22:04, 4F

03/02 22:09, , 5F
VC沒寫在header 不知道做了甚麼事
03/02 22:09, 5F

03/02 22:10, , 6F
就結果來看是沒有檢查
03/02 22:10, 6F

03/02 22:11, , 7F
至於標準要請熟standard的人來回答了
03/02 22:11, 7F
文章代碼(AID): #1BZHViwM (C_and_CPP)
文章代碼(AID): #1BZHViwM (C_and_CPP)