开发者

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("sam开发者_运维百科ple.txt");


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


If you don't specify an absolute path the file name is interpreted to be relative to the working directory of the program.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜