如何从C ++中的字符串获取文件扩展名 [英] How to get file extension from string in C++
本文介绍了如何从C ++中的字符串获取文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定一个字符串filename.conf
,如何验证扩展部分?
Given a string "filename.conf"
, how to I verify the extension part?
一个跨平台的解决方案。
I need a cross platform solution.
推荐答案
你必须确保你处理的文件名多于一个点。
示例: c:\.directoryname\file.name.with.too.many.dots.ext
无法正确处理 strchr
或 find。
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.
我最喜欢的是具有扩展(路径)函数的文件系统库
这篇关于如何从C ++中的字符串获取文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文