Set the PATH to read files from disk.

Hi,

I am dealing with the proccess of read a file from disk. For that I use

 
iFile.open("/home/cristiano/matrix3.dat");


There is some particular way to specify the PATH?

I want to use some thing like

1
2
PATH = "/home/cristiano/";
iFile.open(matrix3.dat);


Thanks.
Make PATH a string. Append your filename to the PATH. (path = PATH + filename;) Use that (path.c_str()) to open your file.
That's not PATH. PATH is the environment variable that stores the directories the system uses to find executable files.

What PG said, but note that you can get the user's ~ with getpwuid().
Use setenv()
http://linux.die.net/man/3/setenv

Keep in mind that may not work... It is better to just build your path like PanGalactic indicated.
Topic archived. No new replies allowed.