title: How to use correctly the return value from std::cin.get() and std::cin.peek()?
body: <p>I've been always using <code>peek(), get()</code> this way:</p>
  <pre><code>int main(){
  
      std::string str;
      int value{};
      if(std::isdigit(std::cin.peek()))
         std::cin &gt;&gt; value;
      else
         std::getline(cin, str);
  
      std::cout &lt;&lt; &quot;value : &quot; &lt;&lt; value &lt;&lt; '\n';
      std::cout &lt;&lt; &quot;str: &quot; &lt;&lt; str &lt;&lt; '\n';
  
  }
  </code></pre>
  <p>And many C++ websites and forums using such a thing:</p>
  <pre><code>while(std::cin.peek() != '\n)
      ; do somthing
  </code></pre>
  <ul>
  <li><p>But after reading the note on C++ primer I am confused. It is said that those functions <code>get(), peek()</code> return an <code>int</code> not a <code>char</code> so we mustn't assign the result into a char but into an <code>int</code>.</p>
  </li>
  <li><p>It is said there that Characters are converted first to <code>unsigned char</code> then promoted to <code>int</code>.</p>
  </li>
  </ul>
  <p>So how could I uses these functions correctly?</p>