Getting the local hostname and/or ip address on Linux
Is there a simple way to get the hostname and/or ip address of the local machine in a C++ program on linux. Want to put it into a string variable.
One way I do it is that I run a System command(something like hostname>hostfile)from the program.....which writes the hostname into a file and then read from the file subsequently...but I kinda don't like it. There ought to be a better way.