我有一个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++;
答案 0 :(得分:0)
您的代码运行正常,因为
line[j] //retrun string
[position] //retrun a specific character in place of position of the line[j]