Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在C++;_C++_Windows_Ofstream - Fatal编程技术网

C++ 在C++;

C++ 在C++;,c++,windows,ofstream,C++,Windows,Ofstream,我查看了论坛,但发现如下: ofstream outfile; outfile.open ("test.txt"); outfile.open ("\\data\\test.txt"); 但我想在同一级别的目录中打开一个文件。我该怎么做 我的C++ exe文件在发布目录中,我需要在日志目录中打开一个文件。 root -somefolder --release --test --log 这不起作用: outfile.open(".\\log\\test.txt",ios::app) 尝试ou

我查看了论坛,但发现如下:

ofstream outfile;
outfile.open ("test.txt");
outfile.open ("\\data\\test.txt");
但我想在同一级别的目录中打开一个文件。我该怎么做

我的C++ exe文件在发布目录中,我需要在日志目录中打开一个文件。

root
-somefolder
--release
--test
--log
这不起作用:

outfile.open(".\\log\\test.txt",ios::app)

尝试
outfile.open(“..\\log\\test.txt”,ios::app)

一个点是当前目录。是的。如有疑问,请键入文件所在的整个位置。