Hi All,
I'm building an integrator, and the way my program's set up now, it recieves the expression from the command line. I was wondering if there was a way to have the expression from the command line be interpreted as actually code ie if x**2 was typed in, to have a value variable that I could set equal to the input expression.
Here's my code:
Code:#include <math.h> #include <stdio.h> double fofex( int argc, char *argv[], double var_v ); main(int argc, char *argv[]){ double ans; ans = fofex(argc, argv, 2); printf("Value of %s at 2 is: %f",argv[1], ans); /*Feed function pointer to expression and variable value*/ double fofex(int argc, char *argv[], double var_v){ /*Sets variable value to input value*/ double x = var_v; /*Sets value to string of expression, which must contain 'x'...*/ printf("Inside the function expression is %s\n", argv[1]); double value = argv[1]; return (value); } }
And of course I get an error because of incompatible types between value ad argv[1]. Is there a way to do what I'm trying to do? Thanks in advance.



LinkBack URL
About LinkBacks



