windows 如何解析 C 中绝对路径的相对路径?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8354422/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 18:34:19  来源:igfitidea点击:

How do I resolve a relative path to an absolute path in C?

cwindowsfilepath

提问by Jojje

I have a C console app where I need to output the absolute path to a file given a (possibly) relative path. What is the best way to do this in C in a Windows environment?

我有一个 C 控制台应用程序,我需要在其中输出给定(可能)相对路径的文件的绝对路径。在 Windows 环境中用 C 执行此操作的最佳方法是什么?

回答by Prof. Falken contract breached

I think you are looking for _fullpath().

我认为您正在寻找_fullpath()

回答by nullpotent

GetFullPathNameshould help you on Windows.

GetFullPathName应该可以帮助您在 Windows 上。

GetFullPathName merges the name of the current drive and directory with a specified file name to determine the full path and file name of a specified file.

GetFullPathName 将当前驱动器和目录的名称与指定的文件名合并,以确定指定文件的完整路径和文件名。