Code:#define SIZE1 40 #define SIZE2 1024 #include <stdio.h> #include <ctype.h> void Instructions(void); void generateRandStr(char *); char userString(char *); void strFilter(char *, char *, char); void main(void) { char s1 [SIZE1], s2 [SIZE2], c, proceed;// buffer[81]; generateRandStr(s1); do { Instructions(); puts("\nRandomly Generated String: "); puts(s1); c = userString(s2); puts("\nUser Entered String:"); puts(s2); strFilter(s1, s2, c); puts("\nDo you wish to continue?"); printf("Press enter to proceed, any other key to exit: "); scanf("%*c%c", &proceed); if(proceed != '\n') puts("\nGoodbye!"); } while(proceed == '\n'); } void Instructions() { puts("\nThis program creates a random string of 40 characters."); puts("The user enters a string (following certain rules)"); puts("and then enters a replacement character."); puts("The program then compares the user string with the random string"); puts("and replaces any instances of the same character(s) with"); puts("the replacement character, and displays the 'filtered' string."); } void generateRandStr(char *ps1) { int n; char *pps1; for(pps1 = ps1; pps1 < ps1 + SIZE1; pps1++) { n = rand(); *pps1 = (n % 26) + 'A'; } *pps1 = '\0'; } char userString(char *ps2) { int count, error; char c, ch, *pps2; do { pps2 = ps2; count = error = 0; puts("\nEnter a string of maximum 20 characters(no #s, symbols, punctuations etc):\n"); ch = toupper(getchar()); while(count < SIZE2) { while(ch != '\n' && !error) { if(ch >= 'A' && ch <= 'Z') { *pps2 = ch; pps2++; count++; ch = toupper(getchar()); } else { puts("Error: Invalid character found...Please re-enter"); error = 1; gets(ps2); // clears the buffer } } count = SIZE2 + 1; // exit loop when error or '\n' } *pps2 = '\0'; for(count = 0, pps2 = ps2; *pps2 != '\0'; pps2++, count++); if(count <= 1 || count > 20) puts("\nError: String out of range...Please re-enter"); } while(count <=1 || count > 20 || error); puts("\nEnter (any) replacement character: "); scanf("%c", &c); printf("\nReplacement Character: \t%c", c); return(c); } void strFilter(char *ps1, char *ps2, char c) { char temp [SIZE1], *ptemp, *pps1, *pps2; for(pps1 = ps1, ptemp = temp; *pps1 != '\0'; pps1++, ptemp++) *ptemp = *pps1; *ptemp = '\0'; for(pps2 = ps2; *pps2 != '\0'; pps2++) for(ptemp = temp; *ptemp != '\0'; ptemp++) if(*ptemp == *pps2) *ptemp = c; puts("\nFiltered String:\t"); puts(temp); }