title: Can't std::ostream output a const char array?
body: <p>For the fun and experience of it, I'm <del>modifying and</del> exploring the source code for <a href="https://sourceforge.net/projects/blobby/files/Blobby%20Volley%202%20%28Linux%29/1.0/blobby2-linux-1.0.tar.gz/download" rel="noreferrer">Blobby Volley 2 1.0</a> (Linux).</p>
  
  <p>Well... I <strong>would</strong> be modifying the source code, but I can't even get the program to compile. (Sad, isn't it?)</p>
  
  <p>Here's the code that causes the error:</p>
  
  <pre><code>std::ostream&amp; operator&lt;&lt;(std::ostream&amp; stream, const ServerInfo&amp; val) {
      return stream &lt;&lt; val.name &lt;&lt; " (" &lt;&lt; val.hostname &lt;&lt; ":" &lt;&lt; val.port &lt;&lt; ")";
      }
  </code></pre>
  
  <p>Trying to compile this with <em>g++ 5.4.0</em> gives the following (simplified output--the original output is ~443 lines) error message:</p>
  
  <blockquote>
    <p>error: no match for ‘operator&lt;&lt;’ (operand types are ‘std::ostream {aka
    std::basic_ostream}’ and ‘const char [32]’)</p>
    
    <p>return stream &lt;&lt; val.name &lt;&lt; " (" &lt;&lt; val.hostname &lt;&lt; ":" &lt;&lt; val.port &lt;&lt; ")";</p>
  </blockquote>
  
  <p>I simplified the code to this:</p>
  
  <pre><code>std::ostream&amp; operator&lt;&lt;(std::ostream&amp; stream, const ServerInfo&amp; val) {
      stream &lt;&lt; "hello"; //can't get simpler than this, right?
      return stream;
      }
  </code></pre>
  
  <p>and got</p>
  
  <blockquote>
    <p>error: no match for ‘operator&lt;&lt;’ (operand types are ‘std::ostream {aka std::basic_ostream}’ and ‘const char [6]’)</p>
    
    <p>stream &lt;&lt; "hello";</p>
  </blockquote>
  
  <p>The code that calls it looks like this:</p>
  
  <pre><code>std::cout &lt;&lt; "duplicate server entry\n";
  std::cout &lt;&lt; info &lt;&lt; "\n"; //it's called here
  </code></pre>
  
  <hr>
  
  <p>The thing I find most surprising is that we all know that <code>std::cout</code> and its ilk can handle <code>char</code> arrays.</p>
  
  <p>For instance,</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  int main () {
      const char a[6] = "hello";
      std::cout &lt;&lt; a &lt;&lt; std::endl; //No problem here!
      return 0;
      }
  </code></pre>
  
  <p>works without a hitch.</p>
  
  <hr>
  
  <p>Oh, one more thing.</p>
  
  <p>If I include <code>&lt;string&gt;</code>, this works:</p>
  
  <pre><code>std::ostream&amp; operator&lt;&lt;(std::ostream&amp; stream, const ServerInfo&amp; val) {
      stream &lt;&lt; std::string("hello");
      return stream;
      }
  </code></pre>
  
  <hr>
  
  <p>Does anyone know what I'm missing?</p>
  
  <hr>
  
  <p><strong>PS:</strong> Here's a <a href="http://pastebin.com/UYPHqspD" rel="noreferrer">pastebin of the errors.</a></p>
  
  <p><strong>PPS:</strong> Here's the headers that were requested:</p>
  
  <pre><code>/* header include */
  #include "NetworkMessage.h"
  
  /* includes */
  #include &lt;cstring&gt;
  
  #include "UserConfig.h"
  #include "SpeedController.h"
  </code></pre>
  
  <p><strong><em>PPS:</em></strong> If you are wondering why I didn't get an error about <code>std::ostream</code> not being defined, check the 3rd paragraph of Sam's answer.</p>