发布网友 发布时间:2022-05-15 10:31
共3个回答
热心网友 时间:2023-08-03 00:44
是在strParagraph.erase(intPuncCheck)运行后,strParagraph的长度就变短了,再按照开始的长度去循环就会出错;追答//for (int intPuncCheck = 0;
// intPuncCheck <= intLenOfParaFixed;
// intPuncCheck++)
int intPuncCheck = 0;
while(intPuncCheck<strParagraph.length())
{
if (strParagraph[intPuncCheck] == ',')
{
strParagraph.erase(intPuncCheck,1);
}
intPuncCheck++;
}
你是想删除所有的',',那么要改成,strParagraph.erase(intPuncCheck,1);
热心网友 时间:2023-08-03 00:44
报的什么错误?可以将错误的代码贴出来。热心网友 时间:2023-08-03 00:45
哪儿报错,我运行没错啊,看你报的错是下标越界了啊,intPuncCheck 那就不能等于intLenOfParaFixed追问A metaphysical being, Death serves as the dryly cynical narrator of The Book Thief.