I think you are on a Linux or POSIX system with an interactive shell that understands ~(for example, bash)
, ~, ( mkdir '~' , ). , globbing , ( !) ~, . /home/martin myprogram ~/example.txt . . glob (7). , glob (3) wordexp (3) ++ ( , "~/example.txt" - , - , ..)
getenv (3), ( getpwuid (3) getuid (2)). ,
std::string home=getenv("HOME");
std::string path= home+"/example.txt";
ofstream myfile(path);
, , getenv("HOME") NULL. .
. .