title: How to print duplicate letters in a string with their count number in C?
body: <p>I have been implemnting an algorithim for counting and printing duplicate letters (two times or more) in a C string.</p>
  
  <p>Example :
  If input string was : <code>"Hello There"</code>
  The output should be :</p>
  
  <pre><code>e - 3
  h - 2
  l - 2
  </code></pre>
  
  <p>My current code has been printing what i need,but it <strong>doesn't consider capital letters</strong>, it also keep giving me the message <code>stack smashing detected (core dumped)</code> . So, it doesn't work properly and I'm not sure why :</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main()
  {
     char string[10];
     int c = 0, count[26] = {0};
  
     printf("Enter a string of size [10] or less:\n");
     gets(string);
  
     while (string[c] != '\0')
     {
        /**reading characters from 'a' to 'z' or 'A' to 'Z' only
            and ignoring others */
  
        if ((string[c] &gt;= 'a' &amp;&amp; string[c] &lt;= 'z') || (string[c] &gt;= 'A' &amp;&amp; string[c] &lt;= 'Z'))
  
        {
           if (string[c] &gt;= 'a' &amp;&amp; string[c] &lt;= 'z')
           {
           count[string[c]-'a']++;
           }
           else if (string[c] &gt;= 'A' &amp;&amp; string[c] &lt;= 'Z')
           {
           count[string[c]-'A']++;
           }
        }
  
        c++;
     }
  
     for (c = 0; c &lt; 26; c++)
     {
        /** Printing only those characters
            whose count is at least 2 */
  
        if (count[c] &gt; 1)
           printf("%c - %d \n",c+'a',count[c]);
     }
  
     return 0;
  }
  </code></pre>