看板 C_and_CPP 關於我們 聯絡資訊
若我要輸入"CS101 Introduction to C++ Programming," 用cin>>string1; //只能讀到CS101 用getline(cin,string1); //可以讀完整個句子 C++螞蟻本 5E 在p79第一行有講到The rest of the course name would have to be read by subsequent input operations. 我搞不是很懂,是說第一個cin讀到CS101,第二個cin可讀到Introduction, 第三個cin讀to,... 是這樣嗎? 也就是說我想要用cin讀完整個"CS101 Introduction to C++ Programming," code要使用很多cin cin>>s1; cin>>s2; ... 然後,再把每個小的字串給strcat起來嗎???? thx -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.136.230.97
james732:因為 cin 預設會以空白來切割字串 你可以用個迴圈來讀 09/28 12:00
legnaleurc:或是用 std::copy 09/28 19:18