I don't know how to write applications in C, but I need a tiny program that does:
lh = gethostbyname("localhost");
output = lh->h_name;
output variable is to be printed.
The above code is used in PHP MongoDB database driver to get the hostname of the computer (hostname is part of an input to generate an unique ID). I'm skeptical that this will return the hostname, so I'd like some proof.
Any code examples would be most helpful.
Happy day,
Matic