How to evaluate tokens in C?
<p>I'm trying to work on a program that takes a math expression from user input (2+2, 3*1, 4-2, 2+3*1, etc.) I've goten it to work with simple, one operation, but it doesn't work with multiple yet. I was suggested to tokenize and evaluate the string and while I managed to tokenize it, the manual I'm reading doesn't explain how to evaluate (I'm trying to learn on my own, no schoolwork for me) and google hasn't been super helpful.</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;

int main() {
  char conta[255];
  int n1;
  int n2;
  int result;
  char op;

  printf("Introduza uma expressao numerica: ");
  gets(conta);
  sscanf(conta, "%d %c %d", &amp;n1, &amp;op, &amp;n2);
  char* token = strtok(conta, "+-*/");
  while (token) {
    printf("token: %s\n", token);
    token = strtok(NULL, "+-*/");
  }
  if(op == '+'){
    printf("%d", result=n1+n2);
  }else if(op == '-'){
    printf("%d", result=n1-n2);
  }else if(op == '*'){
    printf("%d", result=n1*n2);
  }else if(op == '/'){
    printf("%d", result=n1/n2);
  }

}
</code></pre>

<p>This is what I have of the code so far. ANy help would be greatly apreciated, thank you.</p>