c++文件IO,如何指定输出位置
C++ File IO, how to specify output location
我一直在尝试通过教程网站学习c++中的File IO,并遇到了以下代码。
现在,我如何指定输出文件的位置?我已经尝试运行代码并搜索文件的位置,但没有工作。
谢谢。
ofstream myfile ("InOutExample.txt");
if (myfile.is_open())
{
myfile << "This is a line.n";
myfile << "This is another line.n";
myfile.close();
}
else cout << "Unable to open file";
return 0;
system("pause");
如果你指定了位置,它会把它放在那里。
ofstream myfile ("c:\temp\InOutExample.txt");
如果你没有输入完整路径,它会把它放在当前工作目录
相关文章:
- 如何在OMNET++中指定与命令行参数组合的输出文件名
- 在张量流中创建新操作时指定形状句柄的形状(输出张量的秩问题)
- put_time具有转换说明符,该转换指定符,该指定符在一个月的单个数字上输出没有前面字符的单位天数
- 如何在使用 cmake -G 时指定输出路径
- 指定输入/输出节点以在加载C API的模型上在Tensorflow 1.0 中运行推理
- CC1plus 错误:输出文件名指定两次
- C++您可以将文件输出到用户指定的目录
- 如何制作一个输出流,将未指定的类型括在C++的括号内
- MSBuild - 如何指定输出文件路径
- 当键入指定单词作为第一个字母时显示输出,并忽略后面的其他单词
- 指定cython输出文件
- Visual Studio 2010:使用define宏指定输出可执行文件
- 在c++中使用内联函数输出未指定的输出
- 为算法指定输入和输出范围
- 当输出放到指定的文件行中时,会覆盖额外的文件行
- 我无法指定为什么输出不正确?
- c++文件IO,如何指定输出位置
- C++ IO 二进制文件流:未指定输出时的默认值
- 按指定字符数缩进多行输出
- 指定要在数组中输出的值