我一次又一次地看到这个烦人的问题。您能否分享您的知识,这可能有助于我们找到答案。
我的困惑是,正斜杠是 posix 标准,但操作系统的目录结构不同。
谢谢
可移植 fstream 文件路径的正确语法是什么?
(例如,您将传递给 std::fstream:open() 以打开文件的字符串。)
一个。 “::目录:文件.bin”
B. "C:/目录/文件.bin"
C. “/目录/文件.bin”
D. "C://目录//文件.bin"
E. std:fstream 文件路径不可移植。
最佳答案
E:不可移植,即实现定义
答案可以在 std::fopen
中找到文档:(由 fstream 通过 filebuf::open 引用)
Notes
The format of filename is implementation-defined, and does not necessarily refer to a file (e.g. it may be the console or another device accessible through filesystem API). On platforms that support them, filename may include absolute or relative filesystem path.
关于c++ - 可移植 fstream 文件路径的正确语法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28853523/