title: C++ 11 int8_t buggy input/output
body: <p>This is a snipped of code from my program. I am using the <code>int8_t</code> data type, and I'm having some problems with input/output. Apparently, using <code>int8_t</code> in the program requires the <code>-std=c++11</code> flag to be set for the <code>g++</code> compiler. I did that, but there are runtime errors. Here's my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdint&gt;
  using std::cout;
  using std::cin;
  using std::endl;
  int main() {
    int8_t number;
  
    cout &lt;&lt; "Enter a number [1-100]: ";
    cin &gt;&gt; number;
    cout &lt;&lt; "You entered: " &lt;&lt; number &lt;&lt; endl;
    cout &lt;&lt; number &lt;&lt; " / 10 = " &lt;&lt; (number / 10) &lt;&lt; endl;
  
    return 0;
  }
  </code></pre>
  
  <p>Here is the output of the program:</p>
  
  <pre><code> $ ./a.out
  Enter a number [1-100]: 95
  You entered: 9
  9 / 10 = 5
  </code></pre>
  
  <p>The <code>$</code> is the shell prompt. Anyway, it seems that only the first digit is read from the input stream. Even so, the integer division <code>9 / 10</code> should return <code>0</code>, not <code>5</code>. This program is intended to do <code>95 / 10</code> and return a result of <code>9</code>. Theoretically, this program should work, but apparently, even the division operator is buggy. I should make a note that using <code>int</code> instead of <code>int8_t</code> causes the program to work as intended. I suspect that in this case someone would just tell me to use the <code>int</code> data type and deal with it. But we are software engineers! I would like to know if the <code>int8_t</code> data type is inherently flawed. Why it can't accept proper user input, but also breaks the division operator?! Any programming language worth using must be free of such imperfections. And I think that C++ is popular enough that eventually someone realized that <code>int8_t</code> is flawed in some sense. That is something I need to know the intricacies of.</p>