title: std::cin skips white spaces
body: <p>So I am trying to write a function to check whether a word is in a sentence, by looping through a char array and checking for the same string of char's. The program works as long as the Sentence doesn't have any spaces. I googled around and they are all the same suggestions;</p>
  
  <pre><code>cin.getline
  </code></pre>
  
  <p>But however I implement it, it either doesn't run or skips the entire input and goes straight towards the output.</p>
  
  <p>How can I account for spaces?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  
  using namespace std;
  
  bool isPartOf(char *, char *);
  
  int main()
  {
  char* Word= new char[40];
  char* Sentence= new char[200];
  
  cout &lt;&lt; "Please enter a word: ";
  cin &gt;&gt; Word;
  cout &lt;&lt; endl &lt;&lt; "Please enter a sentence: "; 
  
  //After Word is input, the below input is skipped and a final output is given.
  cin.getline(Sentence, 190); 
  cout &lt;&lt; endl;
  
  if (isPartOf(Word, Sentence)==true)
      {
          cout &lt;&lt; endl &lt;&lt; "It is part of it.";
      }
  else
      {
         cout &lt;&lt; endl &lt;&lt; "It is not part of it.";
      }
  }
  
  bool isPartOf(char* a, char* b) //This is the function that does the comparison. 
  {
      int i,j,k;
  
  for(i = 0; b[i] != '\0'; i++)
  {
  j = 0;
  
  if (a[j] == b[i])
  {
      k = i;
      while (a[j] == b[k])
      {
  
          j++;
          k++;
          return 1;
          if (a[j]=='\0')
              {
                  break;
              }
          }
  
      }
  
  
  }
  return 0;
  }
  </code></pre>
  
  <p>And I am not allowed to use strstr for the comparison.</p>