A couple of points:
1) The symbol
|
on its own is the bitwise OR operator. If you want to treat it as a character, you need to surround it in single quotes, the way you would any other character. If you want to treat it as a string containing a single character, you need to surround it with double-quotes, like any other string.
Does that line even compile?
2) Even if you treated it as a string,
if (cin>>"|")
wouldn't do what you seem to think it does. If you look at the reference for the
>>
operator for the
istream class:
http://www.cplusplus.com/reference/istream/istream/operator%3E%3E/
you'll see that the return value is the
istream object itself. ANd if you look at the reference for the overloaded
bool operator for the class:
http://www.cplusplus.com/reference/ios/ios/operator_bool/
you'll see that it tests for whether an error flag on the stream has been set.
What you want to do is:
- use cin to read the user input into a variable
- test the value of the variable to see whether the user typed a | character.
I strongly recommend you go back to your textbook and try and get a better understanding of how to use I/O streams.