Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 31, 2007, 07:09 PM   #1
kegriffin
macrumors newbie
 
Join Date: Aug 2007
fopen and paths in Xcode

I'm using Xcode for a C programming class, and while most of it is over my head, a lot of the features are really helpful. I'm a little puzzled about fopen, though. When I try this

fp = fopen("inventory.data", "r");

fp (which is a FILE*) is 0 during debugging. However, if I use the full path (/Volumes...) it works. I'm required to upload and compile my code on the school's servers, so using those paths is inconvenient. I've put the inventory.data file in my project folder along with the source files, and have added it under the source section in Xcode. Is there some way I can reference the file like this?
kegriffin is offline   0 Reply With Quote
Old Aug 31, 2007, 10:41 PM   #2
Flynnstone
macrumors 65816
 
Flynnstone's Avatar
 
Join Date: Feb 2003
Location: Cold beer land
Does relative files work i.e. fopen("./inventory.data" ...
or use #defines

Code:
#define MAC_OS_X

#ifdef MAC_OS_X
#define INV_FILE /Volume/.../inventory.data
#else
#define INV_FILE inventory.data
#endif
There is a bit better way ...
__________________
"You can't solve your problems with the same level of thinking that created the problems." - Einstein
New iMac 24"/G5 1.8/...
Flynnstone is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Library search paths prello23 iPhone/iPad Programming 2 Apr 8, 2014 12:17 AM
Question about File Paths on Mac doubledee Mac Basics and Help 3 Oct 14, 2013 01:39 PM
Header Search Paths ahan.tm iPhone/iPad Programming 1 Jan 28, 2013 06:34 AM
Obama: only two paths for 'taxes' IBradMac Politics, Religion, Social Issues 161 Dec 19, 2012 11:46 PM
Multiple Index Paths luke3 iPhone/iPad Programming 1 Jul 6, 2012 10:08 PM

Forum Jump

All times are GMT -5. The time now is 05:58 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC