#include#include int main() { std::string str{" Hello, World! "}; std::size_t found = str.find_first_not_of(" \t\n\r\f\v"); if (found != std::string::npos) { std::cout << "Found: " << str[found] << std::endl; } else { std::cout << "No non-space character found." << std::endl; } return 0; }
#includeIn this example, we search for the first non-alphabetic character in a string "123abc456". The character set for which we search for non-matching characters is "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", which represents all alphabetic characters. The expected output is "Found: 1". Cpp std string find_first_not_of is part of C++ standard library under the#include int main() { std::string str{"123abc456"}; std::size_t found = str.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); if (found != std::string::npos) { std::cout << "Found: " << str[found] << std::endl; } else { std::cout << "No non-alphabetic character found." << std::endl; } return 0; }