Created
August 28, 2019 04:16
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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