How to get file extension from string in C++

前端 未结 25 2471
迷失自我
迷失自我 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:24

    You have to make sure you take care of file names with more then one dot. example: c:\.directoryname\file.name.with.too.many.dots.ext would not be handled correctly by strchr or find.

    My favorite would be the boost filesystem library that have an extension(path) function

提交回复
热议问题