Skip to content

Instantly share code, notes, and snippets.

@mrcat323
Last active February 19, 2020 16:37
Show Gist options
  • Save mrcat323/006dcb7a0b4e88a8258c0cef4c6a59d2 to your computer and use it in GitHub Desktop.
Save mrcat323/006dcb7a0b4e88a8258c0cef4c6a59d2 to your computer and use it in GitHub Desktop.
simple stuff to do: just remove all chars which match in the second array
#include <stdio.h>
void squeeze(char s1[], char s2[]);
int main(void)
{
char s1[] = "bad boys for life";
char s2[] = "bad ";
squeeze(s1, s2);
printf("%s", s1);
return 0;
}
void squeeze(char s1[], char s2[])
{
int i, j, k;
for (i = 0; s2[i] != '\0'; ++i) {
for (j = k = 0; s1[k] != '\0'; ++j) {
if (s1[j] != s2[i])
s1[k++] = s1[j];
}
s1[k] = '\0';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment