从C中的路径名中提取基本路径 [英] Extract base path from a pathname in C

查看:225
本文介绍了从C中的路径名中提取基本路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从C中的路径名提取基本路径?

C语言或C运行时库中是否内置任何从C路径名中提取基本路径的功能?

我要问的基本上是的反义词问题.

I'm asking basically the opposite of this question.

注意:我更喜欢跨平台的解决方案,但是我正在Windows中工作,因此,如果仍然有Windows API调用可以做到这一点,我仍然想知道.

NOTE: I prefer a cross-platform solution, but I'm working in Windows so if there is a Windows API call that does this, I'd still like to know.

Input              | Output
---------------------------------
C:\path\to\file   -> C:\path\to\
C:\path\to\file.c -> C:\path\to\
C:\file           -> C:\
.\file            -> .\
.\                -> .\
\                 -> \

参考文献

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆