need some help with C++ file output

Discussion in 'Mac Programming' started by bamdad, Aug 8, 2009.

  1. bamdad macrumors newbie

    Aug 8, 2009
    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:

    	fstream testfile; //test text file used by print_u_values ()"//bamdadhosseini/Desktop/RBF1Dresults/u-test.txt" , fstream::in | fstream::out | fstream::trunc);	
        testfile << "# test results" << endl;
    	fstream matrixtestfile; //test text file used by print_matrix ()"//bamdadhosseini/Desktop/RBF1Dresults/matrix-test.txt" , fstream::in | fstream::out | fstream::trunc);	
        matrixtestfile << "# test matrix" << endl;
    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
  2. bux macrumors regular

    Apr 22, 2004
    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:

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

    / Alex

Share This Page