Concise way to say equal to set of values in C++

后端 未结 5 623
后悔当初
后悔当初 2021-01-23 10:35

For example I have the following string,

if (str[i] == \'(\' ||
    str[i] == \')\' ||
    str[i] == \'+\' ||
    str[i] == \'-\' ||
    str[i] == \'/\' ||
    s         


        
5条回答
  •  走了就别回头了
    2021-01-23 11:02

    You can search for single character str[i] in a string with your special characters: std::string("()+-/*").find(str[i]) != std::string::npos

提交回复
热议问题