J
John Black
Hi,
I have a code to open a file like this,
int r = open("file1", O_RDONLY, 0);
let's say the executable a.out is at <dir> and file1 is also at
<dir>, then no problem.
The problem is when my current directory is at <dir>/<sub_dir> and
file1 is at the sub directory, but a.out is still at <dir>, then when I
run this command,
../a.out
a.out always pick up <dir>/file1, instead of <dir>/<sub_dir>/file1.
Is there any way I can prevent this?
Thanks.
I have a code to open a file like this,
int r = open("file1", O_RDONLY, 0);
let's say the executable a.out is at <dir> and file1 is also at
<dir>, then no problem.
The problem is when my current directory is at <dir>/<sub_dir> and
file1 is at the sub directory, but a.out is still at <dir>, then when I
run this command,
../a.out
a.out always pick up <dir>/file1, instead of <dir>/<sub_dir>/file1.
Is there any way I can prevent this?
Thanks.