opening a file in c++

W

WilliS

Guest
quick question... how would i open a file using xcode... i know i have to do: file.open("extention"); but i really dont know how to enter the extention....

Macintosh HD/Users/Will/Desktop/text.doc

does not work...

anyone have a clue what the exact extention of a file on the desktop would be?
 
OP
W

WilliS

Guest
any c++ gurus out there? i need help opening a text file on my desktop called text.txt...this is my code for one of my functions... it has an if the file open fail, than message that it failed...but i can never get it to work... what do i need to type to get to the file on the desktop??

void get_test_files(ifstream &in_s, ofstream &out_s)
// This function asks users to enter the input and output file names from the keyboard.*
// It will attempt to connect to the files and once successfully connected, it returns the input
// and output streams to the main.* If it fails to connect to the input or output file, it will terminate the program.
{
char originalFile [100];
cout << "Enter the file you wish to convert (ex: Macintosh HD\\Users\\williamlarrison\\Desktop):";
cin >> originalFile;
in_s.open(originalFile);
if(in_s.fail())
{
cout << "Open Failure. Quitting Program";
cout << originalFile;
exit(0);
}
else
cout << "WORKED";
}



*crosses fingers and hopes someone programs in c++*
 
Joined
Mar 9, 2004
Messages
2,860
Reaction score
21
Points
38
Location
Miami FL
Your Mac's Specs
G4 1Ghz OS X 10.4.7
I bet you can open it on the terminal, type Pico >filename< with the right path and then you can edit it.
 
OP
W

WilliS

Guest
i love you :) <3<3<3<3<3

file locations in mac start with / apparently... so instead of something like macintosh hd/users/williamlarrison/desktop... its just /users/williamlarrison/desktop
 

rman


Retired Staff
Joined
Dec 24, 2002
Messages
12,637
Reaction score
168
Points
63
Location
Los Angeles, California
Your Mac's Specs
14in MacBook Pro M1 Max 32GB 2TB
DualG5Lova said:
i love you :) <3<3<3<3<3

file locations in mac start with / apparently... so instead of something like macintosh hd/users/williamlarrison/desktop... its just /users/williamlarrison/desktop


It is more like ~/users/user_name/desktop
 
Joined
Feb 25, 2003
Messages
5,279
Reaction score
138
Points
63
Location
Tropical Island, Jealous?
Your Mac's Specs
MacPro 3.0Ghz 16GB RAM, 4x256 Vid, 30''cinema display
you can open it with your developer tools which are free through apple... right? but its a .doc :D u might as well just open it with like office and copy and paste into xcode. then debug like mad. :)

btw, are you a programmer? Click Here if you are, and tell me if your interested.
 
OP
W

WilliS

Guest
im a freshman in college, majoring in something to do with computers at the moment ;)... im still up in the air about what i want to do..currently leaning toward programming or computer engineering..

but im still pretty much a beginner... ive taken a year of Java, and 2 years of C++...

what are ou looking for? i might be very interested ;)

last summer i held a job working for my school, and the time i wasnt working for the school i wasted away playing a video game lol.. if i had the chance to do some learn more programming...i would jump on it ;)
 
Joined
Feb 25, 2003
Messages
5,279
Reaction score
138
Points
63
Location
Tropical Island, Jealous?
Your Mac's Specs
MacPro 3.0Ghz 16GB RAM, 4x256 Vid, 30''cinema display
FireStorm Creation is looking for skilled builders :)

2 years of C++ and a year of Java is fine. I replied to your PM, hopefully that explains it all.

Right now were just a pass time with the hope of making a little $ to help us through college. Though from what it looks, FSC is going to become pretty big I know I plan on staying in the team till it dies (if it ever does).
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top