title: enter input to a character array with blank spaces in c++
body: <pre><code>int main(){
  
      char str1[MAX], str2[MAX];
      cout &lt;&lt;" 1st string: ";
      cin.get(str1, MAX);
      cout &lt;&lt;" 2nd string";
      cin.get(str2, MAX);
      cout &lt;&lt; str1 &lt;&lt; str2;
      return 0;
  }
  </code></pre>
  
  <p>I am trying to input a string with spaces included in both arrays str1 and str2. The problem is program terminates after taking the first input. </p>
  
  <p>On the output screen:</p>
  
  <p><code>1st string : abc def</code></p>
  
  <p>Now when I press enter to take input for 2nd array but then the code terminates and first string is displayed.</p>
  
  <p>Output:
  2nd string</p>
  
  <p><code>abc def</code></p>
  
  <p>How can I properly use this cin.get() function to take 2 different inputs? Is there any other way to take string with blank spaces for char array ?</p>