title: Input from an istream to a char* pointer?
body: <p>I am reading Bjarne Stroustrup's &quot;Programming Principles and Practice Using C++&quot; (second edition). On page 660-661, the writers define a function as follows:</p>
  <pre class="lang-cpp prettyprint-override"><code>istream&amp; read_word(istream&amp; is, char* buffer, int max)
      // read at most max-1 characters from is into buffer
  {
      is.width(max);    // read at most max-1 characters in the next &gt;&gt;
      is &gt;&gt; buffer;     // read whitespace-terminated word,
                        // add zero after the last character read into buffer
      return is;
  }
  </code></pre>
  <p>Later in <code>int main()</code>, the function is called as <code>read_word(cin,s,max);</code> where <code>cin</code> is <code>std::cin</code>, <code>max</code> is an <code>int</code>, and <code>s</code> is a <code>char</code> array of size <code>max</code>.</p>
  <p>I don't understand how <code>is &gt;&gt; buffer;</code> works. In particular, that line gives an error when I tried to run the code:</p>
  <blockquote>
  <p>C2679 binary '&gt;&gt;': no operator found which takes a right-hand operand of type 'char *' (or there is no acceptable conversion)</p>
  </blockquote>
  <p>There is no user-defined <code>operator&gt;&gt;</code> or further explanation on that line (except the comment) in the book.</p>
  <p>I wonder if we can use things like <code>is &gt;&gt; buffer;</code> in any meaningful way? If so, how does it work? Or is this an error in the book?</p>
  <hr />
  <p><strong>Update</strong>: I'm using Visual Studio 2022. I found that the code runs successfully with C++14/17, but not with C++20. The results are similar for clang and gcc.</p>