title: How to count numbers and characters of a string?
body: <p>I have to do this excercise and I'm really trying to do my best, but I can't figure out how to solve it. </p>
  
  <p>It says I need to code a program to analyze a string. And it needs to give the numbers of words and numbers.</p>
  
  <p>Note that a number is also a word.
  123 is a word and a number, but for example 4HIMATE is not a number, only a word.</p>
  
  <p>I'll let my code of what I got so far</p>
  
  <pre><code>int main()
  
  {
  int size= 256;
  
  char s[256]= "Hi 123 Peter 8hi hi8";
  char space[]= " ";
  
  
  int wordCount= 0;
  int numberCount= 0;
  
  strcat(s, space);
  
  strlwr(s);
  
  for(int i= 0; s[i]!='\0'; i++)
  {
      if(s[i+1]== ' ' &amp;&amp; s[i]&gt;96 &amp;&amp; s[i]&lt;123)
      {
          wordCount++;
      }
  
      if(s[i+1]== ' ' &amp;&amp; s[i]&gt;47 &amp;&amp; s[i]&lt;58)
      {
          wordCount++;
      }
  
  }
  
  for (int j=0; j&lt;size; j++)
  {
  
      if(s[j+1]== ' ' &amp;&amp; s[j]&gt;47 &amp;&amp; s[j]&lt;58)
      {
          numberCount++;
      }
  }
  
  printf("Words= %d\n", wordCount);
  printf("Numbers= %d", numberCount);
  
  return 0;
  }
  </code></pre>
  
  <p>My output needs to be=</p>
  
  <p>Words= 5
  Numbers= 1</p>
  
  <p>But the mistake is on numbers, the output is 2.</p>
  
  <p>I don't really know how to solve that, so I need some help.</p>
  
  <p>Corrected some mistakes (edit):</p>
  
  <pre><code> for(int i= 0; s[i]!='\0'; i++)
  {
      if(s[i+1]== ' ' &amp;&amp; s[i]&gt;'a' &amp;&amp; s[i]&lt;'z')
      {
          wordCount++;
      }
  
      if(s[i+1]== ' ' &amp;&amp; s[i]&gt;'0' &amp;&amp; s[i]&lt;'9')
      {
          wordCount++;
      }
  
  }
  
  for (int j=0; s[j]!='\0'; j++)
  {
  
      if(s[j+1]== ' ' &amp;&amp; s[j]&gt;'0' &amp;&amp; s[j]&lt;'9')
      {
          numberCount++;
      }
  }
  </code></pre>