0

I am learning to program C++ and I am using visual studio. In one of my video lectures we are taught how to use an manipulate .txt files. In the video, the instructor creates a .txt file:

ofstream tuesday("snickers.txt");

and it is saved to his desktop as a text file. However, when I do this on visual studio, I am unable to find the .txt file even when I do a full system search. Any help on where this would be saved and how to change the loaction of where it was saved?

python paradise
  • 91
  • 1
  • 2
  • 8
  • try to put an absolute path instead of a relative path. Or execute the program using command line _in_ the executable directory. You may see the file then (unless you have to write something to it, I'm not sure) – Jean-François Fabre Sep 29 '16 at 19:58
  • It's unfortunate that the instructor didn't think to explain to you the concept of "current working directories", instead leaving you to just guess for yourself! – Lightness Races in Orbit Sep 29 '16 at 20:01
  • By default the working directory of a C++ application launched from the Visual Studio integrated debugger is the *project* folder (the folder where the .vcprojx file is located; usually the same, or one folder deeper, than the solution file (.sln) hosting the project). If you're using a default configuration for your project and solution (likely), you should be able to open your .txt file with your posted code if you put in along side your project file). – WhozCraig Sep 29 '16 at 20:01

0 Answers0