Created
October 29, 2018 23:28
-
-
Save jasonthename/c9896c335935c50e6750aac74c3f83e5 to your computer and use it in GitHub Desktop.
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
int paren = 0, brace = 0, brack = 0; | |
for (int ch = fgetc(fp); ch != EOF; ch = fgetc(fp)) { | |
if (ch == '(') paren++; if (ch == ')') paren--; | |
if (ch == '{') brace++; if (ch == '}') brace--; | |
if (ch == '[') brack++; if (ch == ']') brack--; | |
} | |
if (paren != 0 || brace != 0 || brack != 0) { | |
fprintf(stderr, "unbalanced: %d %d %d\n", paren, brace, brack); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment