How can I extract the file name and extension from a path in C++

To extract a filename without extension, use boost::filesystem::path::stem instead of ugly std::string::find_last_of(“.”)

boost::filesystem::path p("c:/dir/dir/file.ext");
std::cout << "filename and extension : " << p.filename() << std::endl; // file.ext
std::cout << "filename only          : " << p.stem() << std::endl;     // file

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)