パスからファイル名を取得

comp.lang.c++ - How to get filename from path in C++


Boost.Filesystem使えば簡単なのにね。

#include <iostream>
#include <boost/filesystem.hpp>

using namespace std;

int main()
{
    boost::filesystem::path path("C:\\a.txt");

    cout << path.filename() << endl; // a.txt
}

こういうのは早く標準でほしいとこです。TR2に期待。


そういえば、Boost.Filesystem V3からは日本語使えるようになるそうですね。