/* * Copyright (C) 2014 Tomasz Kramkowski * * This program is free software. It is licensed under version 3 of the * GNU General Public License. * * You should have received a copy of the GNU General Public License * along with this program. If not, see [http://www.gnu.org/licenses/]. */ #include #include #include #include int *genccountdict(char *); char *nodup(char *, int *); char *nnodup(char *, int *); char *dup(char *, int *); int main(int argc, char **argv) { int i; if(argc!=2) exit(1); char *string = *(argv+1); int *dict = genccountdict(string); for(i = 0; i < strlen(string); i++) string[i] = toupper(string[i]); printf("nodup: %s\n", nodup(string, dict)); printf("nnodup: %s\n", nnodup(string, dict)); printf("dup: %s\n", dup(string, dict)); return 0; } int *genccountdict(char *input) { int *dict = calloc(sizeof(int), 26); int i; for(i=0; i1) output[outpt++]=input[i]; output[outpt] = '\0'; int ndict[26]; memset(ndict, 0, 26*sizeof(int)); return nodup(output, ndict); }