チルダ(~)の展開

man 3 wordexp を使う.

~/image/* にマッチするリストを取る場合は wordexp を使えば良いらしい.

#include <wordexp.h>

int main(int argc, char *argv[])
{
    wordexp_t exp;
    int flags = 0;
    int ret;

    ret = wordexp("~/image/", &exp, flags);

    if (0 == ret){
        // succeed
        int i;
        for (i=0; i<exp.we_wordc; i++){
            printf("%s\n", exp.we_wordv[i]);
        }
     
       wordfree(&exp);
    }

    return 0;
}