converting char to mathematical equation

I have a trouble while converting char to int value .. char variable contains (+) operator which make this problem
the result in serial monitor is 40 =( .. i need it to be 100
thanks in advance

 char sum[]="40+60";
void setup()
{
  Serial.begin(9600);
}

void loop()
{
  int number = atoi(sum);
  Serial.println(number);
  delay(1000);    
}

atoi doesn't do arithmetic.

What are you really trying to do here?

i want convert this char "40+60" to a final value (100)
"40+60" will be generated from voice recognition arduino shield

You need to parse the expression.
Reverse-Polish might be an easier task, if expressions get any more complex.

AWOL:
You need to parse the expression.
Reverse-Polish might be an easier task, if expressions get any more complex.

what's reverse polish ?? :~

what's reverse polish ??

This is NOT the "google it for me" hotline. Do it yourself!

Read about a classic algorithm for evaluating math expressions ("My Dear Aunt Sally") here: Byte Magazine Volume 00 Number 06 - Color Graphics : Free Download, Borrow, and Streaming : Internet Archive

MohammedS:

AWOL:
You need to parse the expression.
Reverse-Polish might be an easier task, if expressions get any more complex.

what's reverse polish ?? :~

Hewlett-Packard calculator fans will remember.....

AWOL:
Reverse-Polish might be an easier task, if expressions get any more complex.

However 40+60 isn't Reverse Polish. :stuck_out_tongue:

MohammedS:
i want convert this char "40+60" to a final value (100)
"40+60" will be generated from voice recognition arduino shield

Can you recognize "40"?

Can you recognize "60"?

Can you recognize "plus"?

Can you add (hehe) all that together?

Indeed, that would be 40 Enter 60 +

(There's a clue, MohammedS)