Storing Math expression as vector

This is a discussion on Storing Math expression as vector within the C++ Programming forums, part of the General Programming Boards category; okay so I have set up the following input which is a reverse polish notation expression that I need to ...

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    27

    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.

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

    Code:
    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 04:34 PM.

  2. #2
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    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, 01: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, 06:15 AM
  4. Push_back not storing data to vector
    By csonx_p in forum C++ Programming
    Replies: 13
    Last Post: 07-27-2008, 05:38 AM
  5. Help with making a Math Expression DLL
    By MindWorX in forum C Programming
    Replies: 19
    Last Post: 07-20-2007, 12:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21