std::string filename = "document.txt"; std::string extension = ".txt"; if (filename.ends_with(extension)) { // file has the correct extension }
std::string url = "https://www.example.com/product"; std::string domain = "example.com"; if (url.ends_with(domain)) { // URL is from the correct domain }Package/Library: The String EndsWith function is a part of the C++ Standard Library.