Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > specify path for I/O

specify path for I/O
Thread Tools
Mac Enthusiast
Join Date: Apr 2003
Location: manticore or people's republic of haven
Status: Offline
Reply With Quote
Feb 27, 2005, 12:01 PM
 
how do i specify a place to save/read a file? the book i am using for class is written with windows compilers/filesystems in mind and i have looked at the documentation in xcode and cannot figure out what i need to do to change where the file is saved to or read from. the example from the textbook (the part i am having problems with) is:
Code:
ifstream in("a:Name.txt"); in.getline(name, 15);
where the previous example created Name.txt and in the current file, name is declared as char name[15] previously. i have changed the code to match the location on my local machine, but nothing is read in. do i need to include something other than iostream.h and fstream.h?

i can compile, build, and run but my run log window shows me nothing other than "session started at . . ."

thanks!
some people are like slinkys: they don't do much, but are fun to push down stairs.
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Feb 27, 2005, 04:34 PM
 
Specifying a POSIX file path should work. Are you sure that everything is where you think it is?
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Mac Enthusiast
Join Date: Apr 2003
Location: manticore or people's republic of haven
Status: Offline
Reply With Quote
Feb 28, 2005, 06:50 PM
 
Originally posted by Chuckit:
Specifying a POSIX file path should work. Are you sure that everything is where you think it is?
how would i do that? and yeah, the file name is correct. i have tried specifying by the drive name and also just the file name. should i specify full path name, beginning from root?

nick
some people are like slinkys: they don't do much, but are fun to push down stairs.
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Feb 28, 2005, 07:02 PM
 
You should specify the name just as if you were typing it into the shell (except without any shell shortcuts like $HOME, of course). If you are in the directory with the file, just the file name will work. Absolute paths will work no matter where you are. For instance, replacing "a:Name.txt" with "/Users/chuck/Name.txt" will open the file if it's in my home folder.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Mac Enthusiast
Join Date: Apr 2003
Location: manticore or people's republic of haven
Status: Offline
Reply With Quote
Feb 28, 2005, 07:11 PM
 
Originally posted by Chuckit:
You should specify the name just as if you were typing it into the shell (except without any shell shortcuts like $HOME, of course). If you are in the directory with the file, just the file name will work. Absolute paths will work no matter where you are. For instance, replacing "a:Name.txt" with "/Users/chuck/Name.txt" will open the file if it's in my home folder.
ok, thank you. will that work for removable drives as well? (ie /volumes/driveName/folder\ Name/fileName.ext)
some people are like slinkys: they don't do much, but are fun to push down stairs.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:12 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2