Home  >  Q&A  >  body text

c++ - What does this conditional statement mean?

Please help explain the meaning of the second if statement of the function
sting::size_type find_char(const string &s,char c,string::size_type &occurs)
{
auto ret = s.size ();
occurs = 0;
for(decltype(ret) i = 0;i != s.size(); i){
if(s[i]==c){

if(ret==s.size())//这个if语句有什么意义
  ret = i;
++occurs;

}
}
return ret;
}

漂亮男人漂亮男人2651 days ago893

reply all(1)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-06-19 09:09:35

    The idea of ​​the second if statement is that when the value of ret is still equal to s.size(), let the value of ret equal i

    reply
    0
  • Cancelreply