所以我正在编写一个程序,其中一部分是处理一个字符串数组,并且从字符串数组中的每个元素中,我试图取出字符串中的每个二元组并将其放在另一个数组中。我正在尝试通过使用 substr 函数来执行此操作,并尝试对其进行调整,但我继续收到 OOR 错误。
代码如下:
“numwords”是字符串数组中的单词数,“lowpunct”是字符串数组
for(i=0; i<numwords;i++)
{
for(x=0; x<=lowpunct[i].length()-2;x++)
{
if(lowpunct[i].length()-2 <=0)
{
bigram[count]=lowpunct[i];
count++;
}
else
{
bistring=lowpunct[i].substr(x,2);
bigram[count]=bistring;
count++;
bistring="";
}
}
}