【发布时间】:2017-06-10 01:36:50
【问题描述】:
std::string file = "Cell.txt";
myfile.open (file);
在当前程序文件夹中创建一个文件。我不希望文件与正在编写它们的程序混在一起。
std::string file = "Cell\\Cell.txt";
什么都不做
std::cout << file << '\n';
打印 Cell\Cell.txt
我什至尝试过
std::string file = "\\Cell\\Cell.txt";
没想到会这样,但还是尝试了
std::string file = "\\\\Cell\\\\Cell.txt";
我以前做过,网上什么都帮不上
【问题讨论】:
-
文件路径必须存在才能打开文件。 Check out this thread.
-
不使用windows
-
文件夹单元格确实存在。运行程序,制作,运行程序,删除它,尝试不同的东西,......
-
考虑使用 c++17 中的新文件系统库(或旧版本标准中的实验性文件系统库)来执行构建路径和创建目录等操作。