如何访问 <int,字符串>映射中的特定字符?



我在C++中有一个映射,我只想访问字符串中的特定字符。我有一个看起来像这样的循环。

map<int, std::string> line; 
for (int j = position; j < position+WIDTH; j++)
{
    // get the next number
    int number = convertToInt(line[j][position]); // <---Need only 1 char
    std::cout << "Number :: " << number << std::endl;
}
position++;

您的代码工作正常,因为

line[j]   //retrun string
[position]   //retrun a specific character in place of position of the line[j]

最新更新