How to use an array index as an operator?
Such that:
#include
main()
{
char sign[]={\'+\',\'-\'};
int a, b;
a = 12 sign[1] 10
I'd be tempted to use a ternary for this:
a = 12 + (sign[1] == '-' ? -1 : +1) * 10;
Of course this defaults to +
but you could introduce earlier checks to guard against that.
You could use this to form a macro:
12 + SIGN(1) 10;
with
#define SIGN(s) (sign[(s)] == '-' ? -1 : +1) *
which recovers the form of the expression in your question excepting the square brackets.