title: Count words from a string with multiple empty spaces
body: <p>I need code that can count the words from a string without counting multiple spaces between them.</p>
  
  <p>I could code a program that counts the words with only 1 empty space between them, but I don't know how I should code it when it would be more than 1 empty space. I thought something like a <code>for</code> loop that checks if the char before it is a space, but I don't know how to do that. And I want to mention that I'm a beginner in C.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main()
  {
  char s[200];
  int count = 0, i;
  
  printf("enter the string: ");
  fgets(s,200,stdin);
  for (i = 0;s[i] != '\0';i++)
  {
      if (s[i] == ' ')
          count++;    
  }
  printf("number of words in given string are: %d\n", count+ 1);
  
  return(0);
  } 
  </code></pre>