//implement a calculator //no bracket #include <iostream> #include<cctype>//the 'isdigit' which was included in it will be used in the funcion named number; #include <cstdlib> using std::cin; using std::cout; using std::endl; void eatspaces(char * str); double number(const char * str, size_t & index); double expr(const char *str); double term(const char *str, size_t & index); int main() { const int max{ 80 };//length of the expression char buffer[max]{}; cout << endl << "enter an expression , or an empty line to quit :" << endl; while (1) { cin.getline(buffer, sizeof buffer);//get an expression from keyboard cout << "the expression you enter is : " << buffer<<endl; eatspaces(buffer); cout << "the expression without spaces is : " << buffer << endl; double value{}; //size_t index{}; value = expr(buffer);//calculate the expression //value = number(buffer, index);//be use to test whether the function "number" is on work cout << "the value :" << value << endl; if (buffer[0] == 0) return 0; } //cout << endl; return 0; } /*expr :calculate the expression got from buffer*/ double expr(const char *str) { double value{}; size_t index{};//this index will be used from now to the end ,which show as a '&' //divide the expression into term according to the '+' or '-' value=term(str, index);//the beginning term for (;;) { char temp{ *(str + index) }; index++; cout << "test index" << endl; switch (temp) { case '