gpt4 book ai didi

c++ - fopen filename 运行环境

转载 作者:太空宇宙 更新时间:2023-11-04 11:06:01 25 4
gpt4 key购买 nike

在 Windows XP、Windows 7 和 Linux 上使用 C++。

阅读有关文件名的 fopen 文档 ( http://www.cplusplus.com/reference/cstdio/fopen/):

C string containing the name of the file to be opened. Its value shall follow the file name specifications of the running environment and can include a path (if supported by the system).

在这种情况下,“运行环境”是什么意思?操作系统还是文件系统?

如何确定各种平台支持的文件名(无需反复试验)?

最佳答案

这意味着在 Windows 中您需要使用正斜杠指定路径,而在 Linux/Unix 中则使用反斜杠(尽管是文件系统类型)。

Windows 示例文件名: C:/some_path/filename

Unix/Linux/Mac 示例文件名:\some_path\filename

也意味着您不能违反文件名的 namespace ,例如 Windows(NTFS、FAT、...)不允许使用 ? 字符,而 Linux 允许。

因此,这里的“运行环境”可以指操作系统和文件系统。

关于c++ - fopen filename 运行环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25265347/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com