How can i change default dir

Hi rooters,
I’ve written :
ifstream in(“”);
compiler has not found the data file.
And i’ve written:
ifstream in(“c:\root\macros\data files\”)->Is this correct?;
but again has not found the data file.
When i replace the data file in Desktop it finds.
How can i change default place or deroctory (where root can open default)of data file.


Normally root is already the default folder so you don’t have to include that in your path. Also you have to use / instead of .
I would suggest to try it using:

ifstream in("macros/data files/")

But actually I don’t know the command like you posted it. The following works in order to open the energie_SRIM.txt file, which is stored in the folder macros/crosssection/daten/, and to stores it to the array energy

using namespace std;
    const Int_t n=2000;
    Double_t energy[n];

    Int_t i = 0;
    Double_t senergy;
    ifstream inFile;"macros/crosssection/daten/energie_SRIM.txt");
    while (inFile >> senergy) {


To change the current file system directory within a ROOT session callgSystem->cd(where_I_want_to_be);