title: Counting the number of spaces in C program
body: <p>Lowercase and uppercase letters, special characters and numbers are working just fine.
  The program can't count total characters and spaces properly.
  What should I add to make this work? Appreciate your help!</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  #include &lt;ctype.h&gt;
  #include&lt;conio.h&gt;
  
  main(){
  char cMessage[100];
  int  cChar,cLow=0, cUp=0, cSpec=0, cSpace=0, cNum=0;
  
  printf("Enter your message: ");
  scanf("%s", cMessage);
  
  int x=0;
  while(x&lt;strlen(cMessage)){
  
  printf("%c",cMessage[x]);
  cChar++;
  
  if(islower(cMessage[x])){ cLow++;}
  
  else if(isupper(cMessage[x])){ cUp++;}
  
  else if(cMessage[x] == ' '){ cSpace++; }
  
  else if(isdigit(cMessage[x])){ cNum++; }
  
  else{ cSpec++;
  }
  x++;
  }
  printf("\nTotal Characters: %d", cChar);
  printf("\nTotal Lowercase Letters: %d", cLow);
  printf("\nTotal Uppercase Letters: %d", cUp);
  printf("\nTotal Special Characters: %d", cSpec);
  printf("\nTotal Spaces: %d", cSpace);
  printf("\nTotal Numbers: %d", cNum);
  getch();
  
  
  
  }
  </code></pre>