2012/07/03

解決cin與getline()合用的問題

The problem: 

cin>> leaves the newline character (\n) in the iostream.  If getline is used after cin>>, the getline sees this newline character as leading whitespace, thinks it is finished and stops reading any further.


Reference:
http://mathbits.com/mathbits/compsci/APstrings/APgetline.htm (英文原文)
http://csie-tw.blogspot.tw/2007/10/cin-getlinecin-s.html (藏經閣,中文)