Issue
I'm working on a C++ program that needs to use the hostname of the computer it is running on. My current method of retrieving this is by mangling a C API like this:
char *host = new char[1024];
gethostname(host,1024);
auto hostname = std::string(host);
delete host;
Is there a portable modern C++ method for doing this, without including a large external library (e.g., boost)?
Solution
No, there is no standard C++ support for this. You'll either have to make your own function, or get a library that has this functionality.
Answered By - NathanOliver Answer Checked By - Robin (WPSolving Admin)