I’m just looking for some feed back on the following functions. Pretty straight forward and simple, but if additional information is desired, ask and I will gladly oblige. Comments, suggestions, etc are welcomed.
// remove duplicate characters in array word and return the resulting string char * removeDuplicates(char * word){ char * result; int len = strlen(word) + 1; result = malloc (len); if (result == NULL){ errorHandler(2); } for(int i = 0, j = 0; i < len; i++){ char ch; ch = word[i]; if(!targetFound(result, i, ch)){ result[j] = ch; j++; } result[j] = ''; } return result; } // search the characters in array charArray for character target // return a non-zero integer if found, otherwise, return 0 int targetFound(char * charArray, char target){ int found = 0; if(strchr(charArray,target)) found = 1; return found; } // initialize the encrypt array with appropriate cipher letters according to the given key void initializeEncryptArray(char * key, char * encrypt){ char ch; for (int i = 0, j = 0, flag = 0; j < 26;){ ch = key[i]; if (ch == '' || flag == 1){ if(flag == 0) flag = 1; ch = 'Z' - j; j++; } if (strchr(encrypt,ch) == NULL){ encrypt[i] = toupper(ch); i++; } } } // initialize the decrypt array with appropriate cipher letters according to the given key void initializeDecryptArray(char * encrypt, char * decrypt){ int i; for ( i = 0; i < 26; i++){ decrypt[encrypt[i] - 'A'] = i + 'A'; } } // process data from the input file and write the result to the output file // pass the encrypt array to parameter substitute if encryption is intended // pass the decrypt array to parameter substitute if decryption is intended void processInput(char * substitute, FILE * fin, FILE * fout){ char ch; while ( fscanf(fin, "%c", &ch) != EOF ){ if(isupper(ch)){ fprintf(fout, "%c", substitute[ch - 'A']); } else if(islower(ch)){ fprintf(fout, "%c", tolower(substitute[ch - 'a'])); } else fprintf(fout, "%c", ch); } }