使用stoi将字符串转换为int时出错

Runtime Error Message: terminate called after throwing an instance of 'std::invalid_argument' what(): stoi Below is the part of the code. view full code at: https://www.jdoodle.com/embed/v0/25y2 The problem is in coversion when I use inbuilt stoi function int x=stoi(digits); ,rest other code is fine . and digits can be string containing digits from 2-9 inclusive.

vector<string> letterCombinations(string digits)
{
    vector<string>ans;
    string choices[] = { " ", " ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv"};
    int x=stoi(digits);
    res(x,ans,choices,""); //Here res is other function .
    return ans;
}