From f8d9ff23eb8d3e3286ff5cf4d5f9493532991bb7 Mon Sep 17 00:00:00 2001 From: zlg Date: Thu, 16 Jun 2016 10:15:33 -0700 Subject: The massive astyle sweep! Code style should be consistent now. All future commits will be run through astyle or they will be amended. --- ch2/2-04_squeeze-v2.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'ch2/2-04_squeeze-v2.c') diff --git a/ch2/2-04_squeeze-v2.c b/ch2/2-04_squeeze-v2.c index 2c3b56a..7a49585 100644 --- a/ch2/2-04_squeeze-v2.c +++ b/ch2/2-04_squeeze-v2.c @@ -16,13 +16,12 @@ * */ -// It'd be better to make this return a pointer (or string), but the book -// hasn't covered it yet! +/* It'd be better to make this return a pointer (or string), but the book */ +/* hasn't covered it yet! */ void squeeze(char s1[], char s2[]) { int i, j, k, match; - for (i = j = 0; s1[i] != '\0'; i++) { - // I don't see a way to do this without a flag + /* I don't see a way to do this without a flag */ match = 0; for (k = 0; s2[k] != '\0'; k++) { if (s1[i] == s2[k]) { @@ -30,22 +29,18 @@ void squeeze(char s1[], char s2[]) { break; } } - // check our flag. if there wasn't a match, j needs to match i's value + /* check our flag. if there wasn't a match, j needs to match i's value */ if (!match) { s1[j++] = s1[i]; } } - s1[j] = '\0'; } int main() { char foo[16] = "foobarbaz"; char bar[16] = "boz"; - squeeze(foo, bar); - printf("%s\n", foo); // Should read "fara" - return 0; } -- cgit v1.2.3-54-g00ecf