title: Entering multiple strings C++
body: <p>Below code tries to input multiple strings with white spaces and then I need to do comparisons among them. The problem I am facing is that, it is not able to input strings beyond first one. I suppose it the the 'enter' remaining in the input buffer causing this behavior i.e. to skip further input of strings. Any suggestion how to overcome this?</p>
  
  <p>Refered: <a href="https://stackoverflow.com/questions/2765462/how-to-cin-space-in-c">How to cin Space in c++?</a></p>
  
  <p><strong>Edited:</strong> Clear and Flush I have tried to but still same issue.
  I need to implement C style string functions, so can not use string class, the functions strcmp etc have to be implemented by me rather than using library functions. </p>
  
  <pre><code>int main()
      {
          char s[100];
          char s1[100];
          char s2[100];
          char* sub;
  
          struct countSpaces cs;
  
  
  
  cout &lt;&lt; "Enter a String : ";
  cin.get( s, 100 );
  std::cin.clear();
  cs=count(s);
  
  cout &lt;&lt; s &lt;&lt; " contains " &lt;&lt; cs.letters &lt;&lt; " letters and " &lt;&lt; cs.spaces &lt;&lt; " spaces" &lt;&lt; endl;
  cout &lt;&lt; "Length of " &lt;&lt; s &lt;&lt; " is " &lt;&lt; strlen(s) &lt;&lt; endl;
  
  cout &lt;&lt; "Enter First String : ";
  cin.get( s1, 100 );
  std::cin.clear();
  cout &lt;&lt; "Enter second String : ";
  cin.get( s2, 100 );
  std::cin.clear();
  
          if( strcmp(s1,s2) )
          cout &lt;&lt; s1 &lt;&lt; " is equal to " &lt;&lt; s2 &lt;&lt; endl;
          else
          cout &lt;&lt; s1 &lt;&lt; " is not equal to " &lt;&lt; s2 &lt;&lt; endl;
  
  
          return 0;
          }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>$ ./String
  Enter a String : Herbert Schildt
  Herbert Schildt contains 14 letters and 1 spaces
  Length of Herbert Schildt is 15
  Enter First String : Enter second String :  is not equal to
  </code></pre>