我已经创建了两个向量o3
(一个向量来保存来自一个字符串的单词)和o4 (a vector to hold those vector of words). In the if statement, once ";" has been found in the vector
o3 [i] , I want to stop putting words from that
o3 [i]`到o4,并转到o3中的下一行。我收到错误“非标准语法使用'&'创建一个指向成员C++”的行,注释为ERROR。任何帮助,高度赞赏。谢谢!非标准语法使用'&'来创建一个指向成员C++的指针
while (getline(myfile, line, (char)32)) // first read entire line into a
//string
// problem : this also reads empty lines
// and gives error
// while returning words
{
abc2.push_back(line); // inserting individual strings into a vector
//cout << abc[i] << "\n"; // use this to see
// them as a vector of lines
//i++;
}
for (int i = 0; i < abc.size(); i++)
{
single_line = abc[i];
if (((single_line[0] >= 'A') && (single_line[0] <= 'Z')) ||
((single_line[0] >= 'a') && (single_line[0] <= 'z')))
{
if (abc[i] != "")
{
o3 = output_words(abc[i], (char)32); // function to separate
//words in a line
int j1 = 0; int j2 = 0;
while (j2 < o3.size())
{
if (o3[j2] != "" && "\t") // *IMP* require this line to
// get words
// irrespective of spaces
{
if (o3[j2].find != ";") // ERROR
{
o4.resize(i + 1);// NO CLUE WHY IT WORKED WITH
// i+1 resize???!!!
o4[i].push_back(o3[j2]);
j2++;
}
else
{
j2++;
}
}
else
{
j2++;
}
}
}
}
else
{
o3 = { "" }; // o1 will be null vector (i.e will contain
// nothing inside)
o4.push_back(o3);
}
}
请编辑您的问题以包含[mcve] – Slava
您可能的意思是“如果(o3 [j2] .find(';')== std :: string :: npos)'或其某些变体。解释你想找到什么,以及一旦找到或找不到,你打算如何处理它。 –
这个问题跟某个主题有关? – Slava