How should I get the fully qualified domain name of "localhost" in c++ (on ubuntu)?

karenc picture karenc · Jan 28, 2010 · Viewed 13.4k times · Source

I've been messing around with getaddrinfo and getnameinfo but the closest I got to useful output was "localhost.localdomain". I'm not sure what to pass in for the "node" or "service" args of getaddrinfo, although I think it's the function I want.

Answer

karenc picture karenc · Jan 28, 2010

Actually, Zxaos's answer here is pretty much the answer I was looking for (even though it's for C and mine was for C++, it works in both):

How do I find the current machine's full hostname in C (hostname and domain information)?

So I guess my question was a duplicate...