title: How to get my code to print the right letter count?
body: <p>I wrote some code to print out the required number of letters inputted into a given text. For some reason after 9 letters it seems to increment by one and will slightly overshoot the number of letters given in the input. Any advice much appreciated :)</p>
  
  <pre><code>// Libraries
  #include &lt;cs50.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  #include &lt;string.h&gt;
  #include &lt;ctype.h&gt;
  
  // Function to count letters
  int count_letter(string text)
  {
      // Declaring function variables
      int lettercount = 0;
      int number_of_letters;
      int spaces = 0;
      int letter_all;
  
      // Getting length of the text
      number_of_letters = strlen(text);
  
      // Counting the letters in the text inputted
      for(lettercount = 0; lettercount &lt; number_of_letters; lettercount++)
         {    // If text is from a-z then count the text
              if(isalpha(text[lettercount]))
                  lettercount++;
              // If text is equal to space then add up the spaces
              else if(isspace(text[lettercount]))
                  spaces++;
              // Minus the spaces from the lettercount
              letter_all = lettercount - spaces;
          }
  
      return letter_all;
  
  }
  
  
  int main(void)
  {
      // Getting a string of Text and storing it in a variable
      string passage = get_string("text: ");
      {
          printf("%i letter(s)\n", count_letter(passage));
  
      }
  
  }
  </code></pre>