Answer the question
In order to leave comments, you need to log in
Why output -1 in find_first_of?
Hello. I can't figure out what is the error in find_first_of? When compiled, it outputs -1, although the condition seems to be set correctly.
...
int num = 0;
string s = "";
string a = "";
getline(fin, s);
getline(fin, a);
while (s != "") {
if (s.find(str, 0) != 1) {
string konec = ".!?";
num = a.find_first_of(konec, 0);
cout << num;
string sub = a.substr(0, num);
if (sub.find(str, 0)) {
cout << sub << endl;
}
a.erase(0, num);
s.erase(0, num);
}
}
...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question