infixcalc#
Simple infix calculator for integer arithmetic Only the following binary operators are implemented:
| logical or
& logical and
= logical equal
! logical not equal
> logical greather than
< logical smaller than
+ plus
- minus
times
/ division
% modulus
^ power
Defines
-
INT_MIN#
Functions
-
int infixcalc(const char *expr, const InfixCalcVariable *vars, size_t nvars, char *err, size_t errlen)#
Parses the infix expression
expr
and returns the evaluated result.The array
vars
lists available variables and should have lengthnvars
. If there are no variables,vars
may be set to NULL.On error INT_MIN is returned and a message will be written to
err
. No more thanerrlen
characters will be written. On successerr[0]
will be set to NUL. If one is not interested to check for errors, one can seterr
to NULL.
-
int infixcalc_depend(const char *expr, const char *varname)#
Returns non-zero if variable
varname
is in expressionexpr
.
-
struct InfixCalcVariable#
- #include <infixcalc.h>
Variable with associated value