Let me explain what I want to do:
I want to change a expression like this: x * (2 + 3) - (y + 1)
to this: 5 * (2 + 3) - (6 + 1)
using this: instVar('x', 5); instVar('y', 6);
My problem is that I only get it to output the "original" expression but not the changed "modified" expression. I don't know why and I was hoping that you might point out to what I am doing wrong.
Here is my code:
void Expression::instVar(char var, int val)
{
    char vars[0];
    int vals[0];
    if(modifiedExpr == "")
    {
        modifiedExpr = originalExpr;
        vars[0] = var;
        vals[0] = val;
    }
    else
    {
        for(int i = 0; i < originalExpr.length(); i++)  //Searching for the var in the original expression
        {
            if(vars[i] == var)  //If the variable is found
            {
                modifiedExpr = originalExpr;    //Setting the expression to the original one so that x can be "replaced"
                vals[i] = val;  //Replace the variable with the value - Does not work :(((
                break;
            }
        }
    }
    //Testing the output if it works
    cout << modifiedExpr << endl;
}
 
     
     
    