It should only look for /home/USER/etc/myfile
if:
- you leave off the leading
/
when calling isfileexists
; and
- that directory
/home/USER
is your current working directory.
In other words, if the argument is a relative path name.
Since you have the leading /
, it will be an absolute path name and should access /etc/myfile
.
If I've misunderstood and you actually want the one in your home directory, you can use getenv("HOME")
to get your home directory and then append /etc/myfile
with strcat
. That will also work regardless of your current working directory.