2nd round: test wireless mouse, given two string remove the occurances of characters in one string from another
Sigiloso
#include #include char *str, *sub; int arr[26]; void main(){ int i = 0, k = 0, j = 0; str = malloc(50 * sizeof(char)); sub = malloc(10 * sizeof(char)); printf("\nEnter main string :"); scanf("%[^\n]s",str); printf("\nEnter second string :"); scanf("%s",sub); while(str[i] != '\0'){ k = str[i] - 'a'; arr[k]++; i++; } i = 0; while(sub[i] != '\0'){ k = sub[i] - 'a'; if(arr[k] > 0){ arr[k] = 0; } i++; } i = 0; while(str[i] != '\0'){ k = str[i] - 'a'; if(arr[k] > 0){ str[j] = str[i]; j++; i++; } else{ i++; } } str[j] = '\0'; printf("\nResult : %s\n",str); getch(); }