#include char userpath[100]; FILE *f; int main (int argc, const char * argv[]) { f = popen("echo ~","r"); while (!feof(f)) { if (fgets(userpath, sizeof(userpath), f)) { // get userpath }} pclose(f); printf("%s",userpath); return 0; }