Suppose I have a string and I want to find whether a specific character (like \'|\') is present or not, what is the best and fastest technique to do so? I know string find i
Use std::string::find
if (str.find('|') != std::string::npos) { // ... }
There's unlikely to be anything more efficient. O(n) is the best you can do. The standard library implementation should be pretty much optimal.