Thread: Storing Math expression as vector

  1. #1
    Registered User
    Join Date
    Feb 2012

    Storing Math expression as vector

    okay so I have set up the following input which is a reverse polish notation expression that I need to turn to vector format to be used with an expression tree. Can anyone give advice? I am also wondering if what I have below is all I need actually.

    std::string in = "3 5 12+25*/";
    Function to change input string to vector form

    int arithmetic_expression::inputRPN(std::string inputString)
        std::vector<std::string> expression = parse_string(inputString);
    //not sure what needs to be done to make into vector here
    Last edited by Chucker; 04-23-2012 at 03:34 PM.

  2. #2
    Internet Superhero
    Join Date
    Sep 2006
    You should loop through the string and push every character that isn't a space onto a std::stack. Just use a for loop and use the brackets to access each character individually.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Storing objects in Vector.
    By darren78 in forum C++ Programming
    Replies: 8
    Last Post: 06-17-2010, 12:18 AM
  2. storing pointers to a templated class in a vector
    By rt454 in forum C++ Programming
    Replies: 4
    Last Post: 01-19-2009, 03:04 AM
  3. Storing a vector inside a vector
    By csonx_p in forum C++ Programming
    Replies: 1
    Last Post: 09-14-2008, 05:15 AM
  4. Push_back not storing data to vector
    By csonx_p in forum C++ Programming
    Replies: 13
    Last Post: 07-27-2008, 04:38 AM
  5. Help with making a Math Expression DLL
    By MindWorX in forum C Programming
    Replies: 19
    Last Post: 07-19-2007, 11:37 PM