This documentation is under development!

infixcalc

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
in addition to parenthesis.

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 length nvars. 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 than errlen characters will be written. On success err[0] will be set to NUL. If one is not interested to check for errors, one can set err to NULL.

int infixcalc_depend(const char *expr, const char *varname)#

Returns non-zero if variable varname is in expression expr.

struct InfixCalcVariable#
#include <infixcalc.h>

Variable with associated value

Public Members

const char *name#

variable name

int value#

value