diff options
author | Adam Carpenter <gitlab@53hor.net> | 2019-07-23 12:09:24 -0400 |
---|---|---|
committer | Adam Carpenter <gitlab@53hor.net> | 2019-07-23 12:09:24 -0400 |
commit | 552bc70b77d4fca54929b46190128721b93d887c (patch) | |
tree | 2793d5aff4fce6b27e1056f89b09b52d41134a4b /ch2/2-4.c | |
parent | e41bafc5885aac630b6d19893e9c80cc334497c2 (diff) | |
download | learning-c-552bc70b77d4fca54929b46190128721b93d887c.tar.xz learning-c-552bc70b77d4fca54929b46190128721b93d887c.zip |
Cleaned up directory.
Diffstat (limited to 'ch2/2-4.c')
-rw-r--r-- | ch2/2-4.c | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/ch2/2-4.c b/ch2/2-4.c deleted file mode 100644 index 3f122bb..0000000 --- a/ch2/2-4.c +++ /dev/null @@ -1,43 +0,0 @@ -#include <stdio.h> - - -void squeeze_char(char s[], char c) { - int i; - int j; - - for (i = j = 0; s[i] != '\0'; i++) - if (s[i] != c) - s[j++] = s[i]; - - s[j] = '\0'; -} - - -void squeeze_str(char s1[], char s2[]) { - int i; - - for (i = 0; s2[i] != '\0'; ++i) - squeeze_char(s1, s2[i]); -} - - -void squeeze_all(char s1[], char s2[]) { - int i; - int j; - int k; - - for (k = 0; s2[k] != '\0'; ++k) { - for (i = j = 0; s1[i] != '\0'; ++i) - if (s1[i] != s2[k]) - s1[j++] = s1[i]; - - s1[j] = '\0'; - } -} - - -int main() { - char squeezed[] = "abracadabra"; - squeeze_all(squeezed,"abc"); - printf("%s\n", squeezed); -} |