Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

HolyKiwi

macrumors newbie
Original poster
Mar 26, 2008
1
0
I'm a comp sci major in college, and our default programming at school/home online console has got to be around 15+ years old now. I was tired of using it due to extreme lag... and started using XCode.

I'm past learning how to open files with C++, but our current assignment requires that one be open. What do I need to do to the file in XCode/Where do I need to put it so that my program can open it? Does it have to be in a specific folder or anything?

The file to be opened is Inventory.txt, and it's in the exact same folder as all the other .cpp and .h files. My coding for opening the program is flawless, as it works on the school's remote desktop'd unix, but at home I get the standard "Cannot open Inventory.txt!" that I added.

I'm using C++ Tool under command line utility.
 
hmmm. I don't have a lot of experience developing on a mac. But, maybe its a permissions issue? Make sure your program will have permission to the file, maybe just chmod 777 it from the terminal.

I would think if the file is with the compiled code (which may be in a different place than your source files) it should be able to open it otherwise.
 
If you don't have an explicit path to the file, then it will look in the working directory of the program. I'm not sure what directory Xcode executes your program from, but it may be in some sort of build directory. There are probably options for that in the project setup.

-Lee
 
The directory that will be used depends on your Build setting. If you have Debug set, the default working directory is

/.../project_name/Build/Debug/.

If your setting is release, it will be

/.../project_name/Build/Release

Todd
 
Hi

Select your program under Executables in Groups & Files and then get info (cmd I). You'll see where the default directory is set to, or you can change it to what you want.

b e n
 
Any success?

I'm in a similar situation, and wherever I place the input text file and however I fiddle with the working directory setting for the app, it seems to make no difference. Very odd. It looks like "Users/.." for ever:confused:
 
I'm in a similar situation, and wherever I place the input text file and however I fiddle with the working directory setting for the app, it seems to make no difference. Very odd. It looks like "Users/.." for ever:confused:

Try a full path, like "/Users/yourname/whatever". The "/" at the beginning would be important.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.