Example 1 — Basic find_last_of
Find the last slash.
#include <iostream>
#include <string>
int main() {
std::string path = "a/b/c.txt";
std::size_t p = path.find_last_of('/');
std::cout << path.substr(p + 1) << '\\n';
return 0;
} How It Works
- Last
'/'is found. - substr after it yields the file name.
- Common path-parsing pattern.

