Programming Tips - C++: get the basename of an absolute filename

Date: 2025apr3 Language: C++ Q. C++: get the basename of an absolute filename A. With C++17 or later use std::filesystem like this
#include <filesystem> std::string basename(const std::string absfilename) { return std::filesystem::path(absfilename).filename(); }