 |
 |
specify path for I/O
|
 |
|
 |
|
Mac Enthusiast
Join Date: Apr 2003
Location: manticore or people's republic of haven
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|