Problems with string subscribt out of range at run time

write a function that divides words based on characters, and the above problem occurs when called.

-sharpinclude<iostream>
-sharpinclude<vector>
-sharpinclude<string>
using namespace std;

vector<string> split(const string& strTemp, char c)
{
    vector<string> str;
    typedef string::size_type size_tp;
    size_tp size = strTemp.size();
    size_tp i = 0, j = 0;

    while (i < size) {
        while (strTemp[i] == c)    PPi;
        j = i;
        while (strTemp[j] != c)   PPj;

        if (i != j) {
            str.push_back(strTemp.substr(i, j - i));
        }
        i = j;
    }
    return str;
}

int main()
{
    string example = "computer/user/mkl/file";
    vector<string> vecanswer = split(example, "/");
    vector<string>::iterator it;
    for (it = vecanswer.begin(); it != vecanswer.end();itPP)
    {
        cout << *it << endl;
    } 
    return 0;
}
CPP
Mar.16,2021

while (strTemp [j]! = c) PPj; is out of range.
determines whether there are any statements that are beyond the std::string size range. while (i < size) is written on the outermost layer, which does not play its due role at all.

Menu