title: Why is the value of closing bracket character sometimes not ')' after reading input from std::cin?
body: <p>I'm running through some C++ tutorials, and I've hit what is probably a trivial issue but is stumping me right now. When I output the value of a closing bracket character in C++ using Xcode 11.3, it sometimes outputs as what looks like a unicode character.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int main() {
  
      int x;
      char ch1, ch2;
  
      std::cin &gt;&gt; ch1 &gt;&gt; x &gt;&gt; ch2;
  
      if (!std::cin || ch1 != '(' || ch2 != ')') {
          std::cout &lt;&lt; "FAIL:\n";
          std::cout &lt;&lt; "ch1 = " &lt;&lt; ch1 &lt;&lt; "\n";
          std::cout &lt;&lt; "x = " &lt;&lt; x &lt;&lt; "\n";
          std::cout &lt;&lt; "ch2 = " &lt;&lt; ch2 &lt;&lt; "\n";
          return 1;
      } else {
          std::cout &lt;&lt; "SUCCESS:\n";
          return 0;
      }
  }
  </code></pre>
  
  <p>In Xcode, the input <code>(2)</code> - inputted as four keystrokes "(", "2", ")" and ENTER - gives the output:</p>
  
  <pre><code>FAIL:
  ch1 = (
  x = 2
  ch2 = \357
  </code></pre>
  
  <p>However if the closing bracket is used as the first character in the stream, it outputs as the character <code>)</code>, as expected.</p>
  
  <p>I'm guessing it something to do with how things are escaped, or possibly some logical error around how I'm using the input stream. Please could anyone let me know what I'm doing wrong?</p>