Search code examples
c++xcode4ifstream

ifstream can't locate file?


I'm trying to read a file called "sample.txt" but whenever i try to do an ifstream, it can never locate the file. So my question is where do you put the file so that it can be located?

 ifstream iFile("sample.txt");

Solution

  • Here is the solution.

    1) Open your project in Xcode;

    2) Locate the Products folder in the Groups & Files tree on the left side of your Project window;

    3) When you expand that folder, you should see the icon for the Unix Executable File (usually a black rectangle);

    4) Ctrl-click on that icon and select Show in Finder_ (If you accidentally choose Open With Finder, the Finder will start your program in a Terminal window);

    5) Show in Finder should bring up a Finder window showing the contents of the folder which includes your executable. You should see your output files in that window.

    Source: https://discussions.apple.com/thread/2145737?start=0&tstart=0