开发者

ifstream can't locate file?

开发者 https://www.devze.com 2023-04-07 14:05 出处:网络
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?

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

精彩评论

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

关注公众号