title: How to print characters with spaces as a string in C++
body: <p>The code is not giving desired output
  when I type in a string example "<strong>Ben Parker</strong>", the output is "<strong>Goodmorning, Ben</strong>" and not the entire name("Ben Parker") what seems to be the problem?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdlib.h&gt; 
  #include &lt;cstring&gt;
  
  int main() {
  char your_name[20];
  
  std::cout &lt;&lt; "Enter your name: ";
  std::cin &gt;&gt; your_name;
  std::cout &lt;&lt; "Goodmorning, ";
  std::cout.write (your_name, strlen(your_name)) &lt;&lt; std::endl;
  
  return 0;
  }
  </code></pre>
  
  <hr>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>This was a very old question when I just began programming. 
  The entire character array can be read and printed with a for loop, or better a <code>string</code> type variable can be used, since it is C++.</p>
  
  <p>using <code>string your_name;</code>  seems to fix the problem, which can be then printed with a simple <code>std::cout &lt;&lt; your_name &lt;&lt; endl;</code></p>