Get the name of the current host
#include <unistd.h> int gethostname( char * name, size_t namelen );
- A buffer where the function can store the host name.
- The size of the buffer.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The gethostname() function stores in name the standard hostname for the current processor, as previously set by sethostname() . The parameter namelen specifies the size of the name array. The returned name is NULL-terminated unless insufficient space is provided.
- An error occurred (errno isn't set).
Hostnames are limited to MAXHOSTNAMELEN characters (defined in <sys/param.h>).