MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   C ++等同于MATLAB的“ fileparts”函数 (https://www.labfans.com/bbs/showthread.php?t=26286)

poster 2019-12-14 20:13

C ++等同于MATLAB的“ fileparts”函数
 
在MATLAB中,有一个很好的函数叫做fileparts,它采用完整的文件路径并将其解析为路径,文件名(无扩展名)和扩展名,如文档中的以下示例所示:

file = 'H:\user4\matlab\classpath.txt'; [pathstr, name, ext] = fileparts(file) >> pathstr = H:\user4\matlab >> name = classpath >> ext = .txt 所以我想知道在我可以使用的任何标准C ++或C库中是否存在等效功能?还是我必须自己实施?我知道这很简单,但是我想知道是否已经有一些预制的东西会更好。

谢谢。



[B]回答:[/B]

一些可能的解决方案,具体取决于您的操作系统:
[LIST][*] Visual C ++ [URL="http://msdn.microsoft.com/en-us/library/e737s6tf.aspx"]_splitpath函数[/URL][*] Win32 [URL="http://msdn.microsoft.com/en-us/library/bb773559.aspx"]Shell路径处理功能,[/URL]例如PathFindExtension , PathFindFileName , PathStripPath , PathRemoveExtension , PathRemoveFileSpec[/LIST]
[url=https://stackoverflow.com/questions/4901999]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 11:25

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.