diff options
author | zlg <zlg@zlg.space> | 2013-02-06 02:47:55 -0600 |
---|---|---|
committer | zlg <zlg@zlg.space> | 2013-02-06 02:47:55 -0600 |
commit | ff8a9aa82f1ea1b18bb859bc053b753f6d6ad238 (patch) | |
tree | ae5f975226b077fde63deb032a7efb6f09f6d0e9 | |
parent | Solve Exercise 1-24: C syntax checker (diff) | |
download | knr-ff8a9aa82f1ea1b18bb859bc053b753f6d6ad238.tar.gz knr-ff8a9aa82f1ea1b18bb859bc053b753f6d6ad238.tar.bz2 knr-ff8a9aa82f1ea1b18bb859bc053b753f6d6ad238.tar.xz knr-ff8a9aa82f1ea1b18bb859bc053b753f6d6ad238.zip |
Fix style issue and correct 1-24
Escape sequences were being compared with the 'or' operator instead of
the 'and' operator. If I had left it alone, every escape sequence
would've borked it.
Diffstat (limited to '')
-rw-r--r-- | 1-24_syntax-checker.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/1-24_syntax-checker.c b/1-24_syntax-checker.c index 239999f..019b9bc 100644 --- a/1-24_syntax-checker.c +++ b/1-24_syntax-checker.c @@ -46,7 +46,7 @@ int main() { escapes++; c = getchar(); // This does not detect all sequences; just the ones covered in Chapter 1. - if (c != '\\' || c != 't' || c != '\'' || c != '"' || c != 'n' || c != 'b' || c != '0') { + if (c != '\\' && c != 't' && c != '\'' && c != '"' && c != 'n' && c != 'b' && c != '0') { break; } else { escapes--; @@ -57,11 +57,11 @@ int main() { if (singqs > 0 || dubqs > 0) { break; } - linenr += 1; + linenr++; } // Parentheses if (c == '(') { - parens += 1; + parens++; } if (c == ')') { parens -= 1; @@ -71,7 +71,7 @@ int main() { } // Brackets if (c == '[') { - brackets += 1; + brackets++; } if (c == ']') { brackets--; |