Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdbool.h>
- #define N 100
- void getstr(char s[]) {
- char c;
- int i = 0;
- while((c = getchar()) != '\n')
- s[i++] = c;
- s[i] = '\0';
- }
- char *filterChars(char s1[], char s2[]) {
- static char ans[N];
- int i = 0, j = 0, k = 0;
- bool filter = false;
- for (i = 0; s1[i] != '\0'; i++) {
- for (j = 0; s2[j] != '\0'; j++) {
- if (s1[i] == s2[j])
- filter = true;
- }
- if (!filter)
- ans[k++] = s1[i];
- filter = false;
- }
- return ans;
- }
- int main() {
- char s1[N], s2[N];
- getstr(s1);
- getstr(s2);
- char *s3 = filterChars(s1, s2);
- printf("%s", s3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment