std::string str("C:\\path.txt"); size_t pos = str.rfind('.'); if(pos != std::string::npos) { std::string ext = str.substr(++pos); if(ext != "gpg") cout << "Errore estensione file"; }