PDA

View Full Version : opening a file in c++



WilliS
03-22-2004, 10:53 AM
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?

WilliS
03-22-2004, 04:59 PM
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++*

witeshark
03-22-2004, 08:43 PM
I bet you can open it on the terminal, type Pico >filename< with the right path and then you can edit it.

WilliS
03-22-2004, 09:07 PM
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
03-23-2004, 09:49 AM
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

Graphite
03-23-2004, 09:59 AM
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 (http://www.firestormcreation.com) if you are, and tell me if your interested.

WilliS
03-23-2004, 11:32 AM
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 ;)

Graphite
03-23-2004, 03:40 PM
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).