I'm trying to write a function that takes 4 characters,with the first and third characters being numbers,and the second and fourth characters being operators,the function converts the the first and third characters into integers,and calculates the output based on the operator between them (or doesn't do that,if the operator stored in the fourth character has a higher priority).

This is my attempt:

```
#include <iostream>
#include<string>

using namespace std;

string calculate(char ch1,char ch2,char ch3,char ch4);

int main() {
    int i = 1;
    string input = "4/1+1-2*2" ;
    string part;
    int leng;
    while(1){

        char cha1 = input[i - 1];
        char cha2 = input[i];
        char cha3 = input[i + 1];
        char cha4 = input[i + 2];
        part = calculate(cha1,cha2,cha3,cha4);
        if (part == "NULL") {
            i += 2;
}
        else{ input = input.replace((i-1),3,part); }
        leng = input.size();
        if (i == leng - 1) {
            i = 1;
        }
    }

}

string calculate(char ch1, char ch2, char ch3, char ch4){
    int in1;
    int in3;
    int result;
    string part;

    if (ch2 == '-') {
        if (ch4 == '*') {
            part = 'NULL';

        }
        else if (ch4 == '/') {
            part = "NULL";
        }
        else {
            in1 = stoi(ch1);
            in3 = stoi(ch3);
            result = in1 - in3;

            part = to_string(result);
        }

    }

    else if (ch2 == '+') {
        if (ch4 == '*') {
            part = "NULL";
        }
        else if (ch4 == '/') {
            part = "NULL";
        }
        else {
            in1 = stoi(ch1);
            in3 = stoi(ch3);
            result = in1 + in3;

            part = to_string(result);

        }
    }

    else if (ch2 == '*') {
        if (ch4 == '*') {
            part = "NULL";
        }
        else if (ch4 == '/') {
            part = "NULL";
        }
        else {
            in1 = stoi(ch1);
            in3 = stoi(ch3);
            result = in1 * in3;

            part = to_string(result);
        }
    }

    else if (ch2 == '/') {
        if (ch4 == '*') {
            part = "NULL";
        }
        else if (ch4 == '/') {
            part = "NULL";
        }
        else {
            in1 = stoi(ch1);
            in3 = stoi(ch3);
            result = in1 * in3;

            part = to_string(result);

        }
    }

    return part;
}

```

The program probably won't work as intended in it's current state,but I'll worry about that later,for now I want to deal with the `stoi()` function,because for every line that contains this function,I get the error in the title.

I want to know what I'm doing wrong,and what this error message exactly means to avoid getting it in the future.

Thank you in advance.