How to get file extension from string in C++

前端 未结 25 2427
迷失自我
迷失自我 2020-11-30 22:35

Given a string \"filename.conf\", how to I verify the extension part?

I need a cross platform solution.

25条回答
  •  抹茶落季
    2020-11-30 23:19

    Using std::string's find/rfind solves THIS problem, but if you work a lot with paths then you should look at boost::filesystem::path since it will make your code much cleaner than fiddling with raw string indexes/iterators.

    I suggest boost since it's a high quality, well tested, (open source and commercially) free and fully portable library.

提交回复
热议问题