c++ - Converting a char "number" into a real int -


i'm wanting take input of user (mathematic expression) , push onto stack. want run through rules ask if '(', number, or operator '+'. problem far don't know how tell, stating inside while loop's first if statement, if char "actually" number. suggestions?

#include <stack>  int main() {     std::stack<char> mystack;    // initializing stack     char line[40];      cin.getline(line, 40);       // , proceeding line input      (int = 0; < 40; i++)         mystack.push(line[i]);   //pushing of char onto stack.      while (!mystack.empty()) {         if (mystack item = number) {         // ^ doesn't compile.         //   need figure out how find out if char number             cout << item << endl;         }         else if (mystack.empty()) {             mystack.push(item);         }     } } 

use isdigit function:

isdigit(x) 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -