[問題] 一個句子(含space)的字串毒入函數[cin與getline]
若我要輸入"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
→
09/28 12:00, , 1F
09/28 12:00, 1F
推
09/28 19:18, , 2F
09/28 19:18, 2F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章