Get the environment variable HOME
. That will be what you should use instead of ~.
Then allocate an array of characters large enough to hold the ultimate full path. This will be the length of the HOME
environment variable, 7 bytes for the /.aexec
, and one more byte for the terminating NUL. Then combine the two strings. If all this is in a loop of any sort, free the allocated string when you're done with it.
For more help:
does this for you while you're inside the editor itself, then vim
is recognizing the ~ and doing something equivalent to this. If you're specifying the file name on the shell command line, it's the shell that's making the same substitution.
Hope this helps.