Last active
September 4, 2019 00:06
-
-
Save gotjon05/365b985e8ee65e156f6e2c12fa2fe557 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> | |
int main() | |
{ | |
char s1[] = {"The course of true love never did run smooth"}; | |
char s2[] = {'o', 'u', '\0'}; | |
squeeze(s1, s2); | |
} | |
void squeeze(char s1[], char s2[]) | |
{ | |
int i, k, j; | |
k = j = 0; | |
for(i = 0; s1[i] != '\0'; i++){ | |
if(s1[i] != s2[k++]){ | |
s1[j++] = s1[i]; | |
} | |
s2[k] = '\0'; | |
} | |
printf("%s", s1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment