从字符串中获取文件名 [英] get filename from string
问题描述
让我们说我有一个字符串" c:\ hello.txt"
我只想要c:\ hello部分,或只是你好 (所以我可以
在文件名的末尾添加一些内容)
i可以使用strrchr(" c:\ hello.txt",' '。'')找到最后一段时间......但是
我不确定指向那个角色的指针对我有什么好处。
any帮助?
Mark写道:让'我说我有一个字符串'c :\ hello.txt"
我只想要c:\ hello部分,或只是你好 (这样我就可以在文件名的末尾添加一些内容)
我可以使用strrchr(c:\ hello.txt,'。'')来查找最后一段时间..但是我不确定指向那个角色的指针对我有什么好处。
任何帮助?
使用std:string,使用find和substr来做你需要的。
-
Ian Collins。
感谢。 cstring函数不是很有帮助。
Mark写道:谢谢。 cstring函数不是很有用。
如果你知道如何使用它们它们很有用。这是一个伪装成
伪装!!!
let''s say i have a string "c:\hello.txt"
and i just want the "c:\hello" part, or just "hello" (so that i can
append something to the end of the filename)
i can use strrchr("c:\hello.txt", ''.'') to find the last period.. but
i''m not sure what good a pointer to that character does me.
any help?
Mark wrote:let''s say i have a string "c:\hello.txt"
and i just want the "c:\hello" part, or just "hello" (so that i can
append something to the end of the filename)
i can use strrchr("c:\hello.txt", ''.'') to find the last period.. but
i''m not sure what good a pointer to that character does me.
any help?
Use std:string, use the find and substr to do what you require.
--
Ian Collins.
thanks. the cstring functions aren''t very helpful.
Mark wrote:thanks. the cstring functions aren''t very helpful.
they are useful if you know how to use them. This is a troll in
disguise!!!
这篇关于从字符串中获取文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!