Hi everyone, i just wanted some advice as to solve my assignment.
i want to write command line calculator that accepts a formula from the user and respond with the calculated result. An example would be:
33.2+2*150/5^2
Which would display:
The answer is : 45.2
So i am considering different things in order to do this:
cin >> user_input ;
int length = user_input.length();
int i;
string array_1[100];
for (i = 0; i<length ; i++)
{
array_1[i] = user_input.substr(i,1);
cout << array_1[i]<< endl;
}
I am placing each character in an array.
I will use "atoi" to convrt char to int , for the calculation
( a problem i face with this is that atoi only accept const char*, how can i resolve this).
And use .find() to give the location of operators (+ - x /).
Do you think that i am heading in the right direction with, this or id there a simple but shorter way?