WHAT IS A CURRENT DIRECTORY?

     
I have a program that I"m attempting lớn write various files to. In an attempt to clean it up I would like to put these files into a directory. My program is running in a directory different from the sln for VS 2012 i.e. The exe is the only part of the VS files in the directory. If I simply print the files, it"s fine but if I attempt to lớn print those same files to lớn a different directory, then it doesn"t do anything. I printed out the directory that I"m attempting to access and I"m getting "000000" as a response. Code looks like:

std::ofstream outputoutput.open("myFilesentityOutput.csv", std::ios::app);output I"m sure it"s something simple but I haven"t been able khổng lồ figure out what. Tried "\myFiles....." already "/myFiles" etc. I"m on a Windows 7 system as well.


*

*

Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first)
That"s because, while opening a file, you need to swap with either \ or /. The reason is that character is considered as a special one that"s used for example khổng lồ represent kết thúc of line character ( ).

Bạn đang xem: What is a current directory?

Just swap output.open("myFilesentityOutput.csv", std::ios::app);to output.open("/myFiles/entityOutput.csv", std::ios::app);, however make sure that the path is also correct!

Usually it"s a good programming practice to check whether or not a file opening succeeded at first.

Xem thêm: Bài Kiểm Tra Tiếng Anh Lớp 2 Có Đáp Án Năm 2021, ✅ Đề Thi Môn Tiếng Anh Lớp 2 Học Kỳ 1


*

Thanks for contributing an answer to lớn Stack Overflow!

Please be sure lớn answer the question. Provide details and share your research!

But avoid

Asking for help, clarification, or responding khổng lồ other answers.Making statements based on opinion; back them up with references or personal experience.

Xem thêm: Phái Nữ Nên Học Võ Gì Để Tự Vệ Tốt Nhất I Nguyễn Đức Mẫn, Con Gái Nên Học Võ Gì

To learn more, see our tips on writing great answers.


Post Your Answer Discard

By clicking “Post Your Answer”, you agree to lớn our terms of service, privacy policy và cookie policy


*

Site kiến thiết / hình ảnh sản phẩm © 2022 Stack Exchange Inc; user contributions licensed under CC BY-SA. Rev2022.12.21.43127


Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device và disclose information in accordance with our Cookie Policy.