Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #define BUFSZ (1024)
- #define DEBUG 1
- int main(void) {
- int i;
- int alphaCount[ 'Z' - 'A' + 1 ];
- int notAlpha = 0;
- char buf[BUFSZ];
- for (i=0;i<sizeof(alphaCount) / sizeof(int);i++)
- alphaCount[i] = 0;
- fgets(buf, BUFSZ, stdin);
- for (i=0;i<strlen(buf);i++) {
- char c = buf[i];
- if (DEBUG) printf("[%c]", c);
- if (islower(c)) {
- alphaCount[ c - 'a' ]++;
- } else if (isupper(c)) {
- alphaCount[ c - 'A' ]++;
- } else {
- notAlpha++;
- }
- }
- for (i=0;i<sizeof(alphaCount) / sizeof(int);i++) {
- printf("%c : %d\n", 'A' + i, alphaCount[i]);
- }
- printf("not alpha : %d\n", notAlpha);
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement