I'm taking my first CS course this summer, and I'm loving it. I'm having a bit of trouble understanding how and when to use cin.get(). I am trying to take an input of numbers followed by a character, to identify which route to take.
std::cin.get( ) returns an integer, not a character. The integer returned is the numerical equivalent to the character entered. You can, however, cast the integer returned to a character using a C-style cast, like this:
Yes, that is correct. Since char can only store a single character, std::cin.get( ) extracts just the one character from the input buffer; in this case, that character is e.
Calling std::cin.get( ) without passing it a buffer( ch ), it will return the numerical equivalent as I previously said. However, if you pass it an input buffer, the character entered is placed into the buffer as a character( obviously, you would except this to happen ).