title: How do I get this getchar() function inside this while loop to return a value? (C)
body: <p>So I'm unfamiliar with the getchar() function in C (because I'm new to programming).<br>
  I want to know how to make the code below take a number of characters (whether thru a file or by inputting from keyboard) and count them with a while loop which has the getchar() function. <br>I want it to read up until the end of a file (or keyboard input).
  As of right now the code doesn't return anything (even if you type in the commandline). <br>
  The OS I'm running this code from is Windows.</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void){
      
      int blanks = 0, digits = 0, letters = 0, others = 0;
      int c; //use for actual integer value of character
      printf(&quot;WELCOME TO WHILE CHARACTER COUNTER: WRITE ANY CHARACTER:\n&quot;);
      
      while ((c = getchar()) != EOF){
          if (c == ' ') //counts any blanks on a text
              ++blanks;
          else if (c &gt;= '0' &amp;&amp; c &lt;= '9')
              ++digits;
          else if (c &gt;= 'a' &amp;&amp; c &lt;= 'z' || c &gt;= 'A' &amp;&amp;  c&lt;= 'Z') 
              ++ letters; 
          else
              ++ others;
  }
  printf (&quot;\nNumber of:blank characters = %d, digits = %d, letters = %d&quot;, blanks, digits, letters);
  
  printf (&quot;\nOther characters = %d&quot;, others);
  
  return 0; 
  }
  
  </code></pre>