title: Why images can be uploaded with char array but not with equal std::istringstream in C++?
body: <p>Consider the code below for a second:</p>
  <pre><code>    char buffer[4000];
      size_t bytes = recv(fd, buffer, 4000, 0);
      write(pipefd[1], buffer, bytes);
      close(pipefd[1]);
      wait(NULL);
  </code></pre>
  <p>Here I read fd, write data to the pipe and close the pipe. This allows to eventually upload tiny images that can be rendered. However, if I do everything the same, only replace char array with std::istringstream, as in the example below:</p>
  <pre><code>    char buffer[4000];
      size_t bytes = recv(fd, buffer, 4000, 0);
  
      std::istringstream data(buffer);
      write(pipefd[1], data.str().c_str(), bytes);
  
      close(pipefd[1]);
      wait(NULL);
  </code></pre>
  <p>Then image is uploaded but cannot be rendered. (Via pipes this C++ program communicates with a php-cgi script).</p>
  <p>Also:</p>
  <pre><code>if (strcmp(data.str().c_str(), buffer) == 0)
   // returns true
  </code></pre>
  <p>I am very curious as to why this could be the case.</p>