title: how to count the number of characters and ignore space in C
body: <p>Following is my code, when I enter "carol chen", I expect it will print out 9 characters, but it print out 10.</p>
  
  <p>The name you enter is: carol chen</p>
  
  <p>The number of characters in the user's name is 10</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  int main(){
  
  char *name;
  int i;
  int n = 0;
  
  name= (char *)calloc(80, sizeof(char));
  
  if(name == NULL) {
  
      printf("\nOut of memory!\n");
      return 1;
  }
  else {
  
      printf("The name you enter is: ");
      scanf("%79[0-9a-zA-Z ]", name);
  
      for(i=0; i&lt;80; i++){
  
          if(name[i] != 0){
  
              n += 1;
          }
      }
  
      printf("\nThe number of characters in the user's name is %d\n", n);
  
  }
  
  free(name);
  
  }
  </code></pre>