#include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct _char_count { char c; int count; struct _char_count *next; } char_count; int main(int argc, char **argv){ int i, j; char_count *headptr, *tmp, *prev; tmp = NULL; prev = NULL; headptr = NULL; for (i=1; i < argc; i++) { for (j=0; j < strlen(argv[i]); j++){ tmp = headptr; while (1) { if(tmp == NULL){ tmp = (char_count *) malloc(sizeof(char_count)); tmp->c = argv[i][j]; tmp->count = 1; tmp->next = NULL; if (headptr == NULL) { headptr = tmp; } else { prev->next = tmp; } break; } else if (tmp->c == argv[i][j]) { tmp->count++; break; } else { prev = tmp; tmp = tmp->next; } } } } for (tmp = headptr; tmp !=NULL; tmp = tmp->next){ printf("%c - %d\n", tmp->c, tmp->count); } return 0; }