문제

I followed the instructions given in this thread for creating a file in a sub-directory.

ofstream forceFile;
forceFile.open(".\\output_files\\error_log.csv", ios::out | ios::app);
forceFile << "stuff" << "\r\n";
forceFile.close();

But now I have files, with size, in the base directory that cannot be opened and are named

.\output_files\error_log.txt

if I double click the file, I am told the file cannot be found and told to try a different path. if I open with notepad++ I am asked if I want to create the file. The an empty file is created in .\output_files

The files are created by my university linux cluster in the university shared server space, then I am viewing the file through an AFS link on my windows laptop.

도움이 되었습니까?

해결책

The problem is that you are using backslashes, not slashes.

The path component delimiter on UNIXes is /, not \.

And because / is not particularly special in a C string, you do not need to escape it with a backslash. So: not \\, not \/ and certainly not //.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top