Putting stuff in $HOME (POSIX)

D

DanielESFA

Hey :)

How would I go about accessing the user's home folder without knowing the
path? I was hoping I could simply use $HOME as in bash, but no donut...

TIA,
Daniel :)
 
D

Donovan Rebbechi

Hey :)

How would I go about accessing the user's home folder without knowing the
path? I was hoping I could simply use $HOME as in bash, but no donut...

That's an easy question, but off topic here. try comp.unix.programmer or
comp.os.linux.development.*
 
L

Larry I Smith

DanielESFA said:
Hey :)

How would I go about accessing the user's home folder without knowing the
path? I was hoping I could simply use $HOME as in bash, but no donut...

TIA,
Daniel :)

#include <cstdlib>
#include <iostream>

int main()
{
char *home;

home = getenv("HOME");

if (home)
std::cout << "HOME: " << home << std::endl;
else
std::cout << "HOME not found" << std::endl;

return 0;
}

Regards,
Larry
 
D

DanielESFA

Larry said:
#include <cstdlib>
#include <iostream>

int main()
{
char *home;

home = getenv("HOME");

if (home)
std::cout << "HOME: " << home << std::endl;
else
std::cout << "HOME not found" << std::endl;

return 0;
}

Regards,
Larry

Beautiful Larry! Thank you very much :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,204
Messages
2,571,063
Members
47,671
Latest member
peterweyand

Latest Threads

Top