How to Write a Boolean Expression Evaluator in C?
I tried to write the most compact C code for this bool expression evaluation problem. Here is my final code: EDIT: deleted Here is the added negation handling: EDIT: test code added char *eval( char *expr, int *res ){ enum { LEFT, OP1, MID, OP2, RIGHT } state = LEFT; enum { AND, OR } … Read more