In the funtion C function link(char *existing, char *new);
existing has to be an absolute path.
But what happens if i want to make a ling to a file in the users home directory (assume file.txt exists)
i cant put in a "~/file.txt" or "./file.txt"
How can i turn the above into the entire path is there a C call to do it
i know the call diname given "~" returns "." which is again what i cant use.
I need some help.
thanks
Please read the rules. There is a link to the rules at the bottom of the page. I deleted the duplicate thread.
link() does not require absolute paths. It will work fine with relative paths. No system call understands the symbol ~ as a directory. That is a shell convention only. You cannot do link("$HOME/filex", "$HOME/bin/filex") either. The symbol ~ is in the boat as $HOME.
I assume that you mean dirname() and not diname(). If so you are misunderstanding how it interprets ~. It thinks that ~ is filename. And it returns . as the parent directory of that file.
If you want to get the user's home directory, you need either the uid or the name of the user. You can use getpwuid() or getpwname() to get the password file entry.