C++ simple program - Why isn't my "res" going into my vector? Creating a program that takes input (4+44-67+235) and outputs the result
<p>I fixed the -'0' errors, and now my output somewhat relates to my input. I believe it's multiplying my first 'c' value by 10, and not the other ones. How would I obtain the correct value of a number like 143 to calculate into my output?</p>

<pre><code>#include &lt;vector&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;

using namespace std;
class token { 
    public: char kind;
            char value;
};

int main(){
    vector&lt;token&gt; vt;
    char c;
    token t;
    int res = 0;
    while (cin&gt;&gt;c){
        if(c!= '+' &amp;&amp; c!= '-' &amp;&amp; c!= '='){

            res = res*10+c-'0';
        }
        else {
            t.kind = c;
            t.value = res;

            vt.push_back(t);
            res = 0;

        }
        if (c=='=')
            break;
    }
    int num = vt[0].value-'0';
    for(int i=0; i&lt;vt.size(); i++){
        if (vt[i].kind=='+')
            num+=vt[i+1].value-'0';
        if (vt[i].kind=='-')
            num-=vt[i+1].value-'0';
    }
    cout&lt;&lt;num;
    system("pause");
}
</code></pre>
