Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bamdad

macrumors newbie
Original poster
Aug 8, 2009
16
0
hi guys

i have just moved to mac and before os x i had linux so anyways, i have been writing some code using C++ and Xcode but i have a silly little problem. i need to create certain folders and then certain .txt files in order to store data. i am using the following lines of code:

Code:
	fstream testfile; //test text file used by print_u_values ()
	testfile.open("//bamdadhosseini/Desktop/RBF1Dresults/u-test.txt" , fstream::in | fstream::out | fstream::trunc);	
    testfile << "# test results" << endl;
	testfile.close();
	fstream matrixtestfile; //test text file used by print_matrix ()
	matrixtestfile.open("//bamdadhosseini/Desktop/RBF1Dresults/matrix-test.txt" , fstream::in | fstream::out | fstream::trunc);	
    matrixtestfile << "# test matrix" << endl;
	matrixtestfile.close();

but i cant get the required files. i have also tried creating all the folders and even the text file but i still cant modify it using C++. i think there's something wrong with the way i'm addressing the files cause i've written the address similar to linux and im not yet familiar with the way OS X file system looks like. thanks in advance
 
As far as I know you need to create the folders, don't think fstream does that for you.

Also, for me it looks like you're trying to access a folder on the desktop for your user?
if so the path should be changed from:
"//bamdadhosseini/Desktop/RBF1Dresults/u-test.txt"
to:
"~/Desktop/RBF1Dresults/u-test.txt"
or:
"/Users/bamdadhosseini/Desktop/RBF1Dresults/u-test.txt"

But maybe I'm wrong with assuming it's your user.
Hope something here helped you!

/ Alex
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.