||=== Guess, Debug ===|
C:\Users\Chay Hawk\Desktop\Guess\main.cpp||In function 'void MAINPROGRAM()':|
C:\Users\Chay Hawk\Desktop\Guess\main.cpp|33|error: invalid use of member (did you forget the '&' ?)|
||=== Build finished: 1 errors, 0 warnings ===|
In this particular case, using getline to get choice in main is probably the superior choice, then you wouldn't be mixing formatted and unformatted input.
If you're referring to cin.peek() on it's own, no. It does exactly what it says. It tells you what the next character in the stream is and leaves it there for the next extraction operation to retrieve.
1. ok so when put like it is above it checks to see if the next line contains whatever the user specifies and if it finds it, it will, in this case, just ignore it right?
2. but it \n still works, a line is still skipped so i guess i dont understand that part.
3. cin.peek(); just checks the next character in the stream, so it only fins text in a cout statement or, what code is next?
cin.peek() tells you what the next character in the stream cin is. That is all that it does. One doesn't need to refer to lines or cout, it is simply the next character that will be extracted from cin.
1 2 3 4
if (cin.peek() == '\n') // if the next character in the stream is a newline...
{
cin.ignore(); // extract and discard the next character in the stream.
}