C Programming Code Examples C > Strings Code Examples Count the Number of Occurrence of each Character Ignoring the Case of Alphabets & Display them Count the Number of Occurrence of each Character Ignoring the Case of Alphabets & Display them #include <stdio.h> #include <string.h> #include <ctype.h> struct detail { char c; int freq; }; int main() { struct detail s[26]; char string[100], c; int j = 0, index; for (j = 0; j < 26; j++) { s[j].c = j + 'a'; s[j].freq = 0; } printf("Enter string: "); j = 0; do { fflush(stdin); c = getchar(); string[j++] = c; if (c == '\n') { break; } c = tolower(c); index = c - 'a'; s[index].freq++; } while (1); string[j - 1] = '\0'; printf("The string entered is: %s\n", string); printf("***********\nCharacter\tFrequency\n************\n"); for (j = 0; j < 26; j++) { if (s[j].freq) { printf(" %c\t\t %d\n", s[j].c, s[j].freq); } } return 0; }