polish notation

I am trying to make a code for polish notation, but it doesn't work. Here's my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <cstdlib>
#include <iostream>
#include <stack>
#include <cstring>

using namespace std;

int polish(char* oper)
{
    int i, o1, o2;
    stack<int> a;
    for (i=0; i<strlen(oper); i++)
    {
        if (int(oper[i])>47 && int(oper[i])<58)
        {
            a.push(oper[i]-'0');
            }
        switch (oper[i])
        {
               case '+':
                    o1=a.top();
                    a.pop();
                    o2=a.top();
                    a.pop();
                    a.push(o1+o2);
                    break;
               case '-':
                    o1=a.top();
                    a.pop();
                    o2=a.top();
                    a.pop();
                    a.push(o1-o2);
                    break;
               case '*':
                    o1=a.top();
                    a.pop();
                    o2=a.top();
                    a.pop();
                    a.push(o1*o2);
                    break;
               case '/':
                    o1=a.top();
                    a.pop();
                    o2=a.top();
                    a.pop();
                    a.push(o1/o2);
                    break;
               }
        }
    return a.top();
}

int main()
{
    char* oper;
    cin>>oper;
    cout<<polish(oper);
    system("pause");
}

It's just one-digit numbers, but im just starting with it and it doesnt work.
Anyone know why?
Because char* needs to be allocated. If you are only working with single digits use char instead of char* on line 55 and &oper on line 57
no i mean single digits becouse it won't work with multi-digit numbers cos it will recognise them like 2 numbers.
Btw: problem solved, I needed to go from right to left, but in this code I searched from left to right. Problem solved!
Topic archived. No new replies allowed.