Possible Duplicate:
What is a fast C or Objective-C math parser?
What function code could I use to convert a dynamic string into an expression and evaluate it ?
#include <stdio.h>
#include <conio.h>
#include <string.h>
int main() {
char var1[] = "3";
char var2[] = "2";
char var3[] = "5";
char exp[20] = "";
int result;
// Trying to create a random expression "(3+2)*5"
strcat(exp, "( ");
strcat(exp, var1);
strcat(exp, " + ");
strcat(exp, var2);
strcat(exp, " ) * ");
strcat(exp, var3);
result = somefunction(exp);
printf("Result : %i\n", result);
return 0;
}