I'm trying to convert infix to postfix. I don't think my code is wrong but apparently it is because it doesn't work. I don't know what to change to make my code work properly.

(It worked for a bit before and now it doesn't)

I followed this code from geeksforgeeks: <https://www.geeksforgeeks.org/stack-set-2-infix-to-postfix/> but I changed some of it because the code from the website was also wrong.

Sorry if my explanation is a bit unclear. Here's my code:

```
#include <bits/stdc++.h>
using namespace std;

int checks(char c)
{
    if (c=='^')
    {
        return 1;
    }
    else if (c=='+' || c=='-')
    {
        return 2;
    }
    else if (c=='*' || c=='/')
    {
        return 3;
    } else
    {
        return -1;
    }
}

int main()
{
    stack <char> stack;
    string result, input;
    cout<<"Enter your equation: ";
    cin>> input;

    for (int i=0; i<input.length(); i+=1)
    {
        if (input[i]=='(')
        {
            stack.push(input[i]);
        } else if (isalnum(input[i]))
        {
            result+=input[i];
        } else if (input[i]==')')
        {
            while(!stack.empty() && stack.top() != '(') 
            { 
                char c = stack.top(); 
                stack.pop(); 
                result += c; 
            } 
            if(stack.top() == '(') 
            { 
                char c = stack.top(); 
                stack.pop(); 
            } 
        } else
        {
            if (checks(stack.top()) >= checks(input[i]))
            {
                result+=stack.top();
                stack.pop();
            } else
            {
                stack.push(input[i]);
            }
        }
    }

    while(!stack.empty())
    {
        if (stack.top()=='(' || stack.top()==')')
        {
            stack.pop();
        } else
        {
            result+=stack.top();
            stack.pop();
        }
    }

    cout<<"Result is: ";
    cout<<result<<endl;
    return 0;
}

```