getline()
reads input until the newline character and
cin>>
fails to remove the newline character after reading input. By calling
getline()
after
cin>>
, you're essentially just grabbing the newline character (and any white space) that
cin>>
left behind.
http://www.cplusplus.com/reference/string/getline/[
^]
You can use
getline()
to get the number as well (just have to take an extra step to interpret as number).