I have trouble understanding what's exactly happening when i put .find() function inside if condition. Similar call in for loop seems to work good.
Part of my code goes like this:
size_t endPos = strbuf.find(endSeq)+endSeq.size();
cout<<endPos<<endl;
if (size_t endPosif = strbuf.find(endSeq)+endSeq.size() != string::npos)
{
cout<<endPosif<<endl;
}
for (size_t endPosfor = strbuf.find(endSeq)+endSeq.size();endPosfor != string::npos;
endPosfor=strbuf.find(startSeq,endPosfor+1)+endSeq.size())
{
cout<<endPosfor<<endl;
}
Output:
466
1
466
What causes this behavior? I would like to use endPosif inside if statement.