Skip to content

Instantly share code, notes, and snippets.

@gotjon05
Created August 28, 2019 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gotjon05/00ec812f1b118823e7c98d465f3dc369 to your computer and use it in GitHub Desktop.
Save gotjon05/00ec812f1b118823e7c98d465f3dc369 to your computer and use it in GitHub Desktop.
write an alternate version of squeeze (s1, s2) that deletes each character in s1 that matches any character in string s2
#include <stdio.h>
void squeeze(char s1[], char s2[]);
int main()
{
char s1[] = {"The course of true love never did run smooth"};
char s2[] = {'a', 'e', 'i', 'o', 'u'};
squeeze(s1[], s2[]);
}
void squeeze(char s1[], char s2[])
{
int a, i, j, k;
for(i = j = 0; s1[i] != '\0'; i++){
if(s1[i] != s2[k++]){
s1[j++] = s1[i];
}
s1[j] = '\0';
}
printf("%s", s1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment