c

How do I achieve tilde expansion in C?


chdir("~/") doesn't seem to work. Am I expected to look at the string and substitute tilde by hand, or is there some better way?


Solution

  • POSIX provides wordexp(3) to perform shell-like expansion, including tilde expansion.