delorie.com/djgpp/doc/libc/libc_400.html | search |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
#include <unistd.h> #include <sys/param.h> int gethostname (char *buf, int size); |
Get the name of the host the program is executing on. This name
is obtained from the network software, if present, otherwise from
the "HOSTNAME"
environment variable, if present, finally
defaulting to "pc"
.
The call fails if more than size characters are required to
specify the host name. A buffer size of MAXGETHOSTNAME
is
guaranteed to be enough.
Zero on success, nonzero on failure.
ANSI/ISO C | No |
POSIX | No |
char *buf = (char *) malloc (MAXGETHOSTNAME); if (buf && 0 == gethostname (buf, MAXGETHOSTNAME)) printf ("We're on %s\n", buf); if (buf) free(buf); |
webmaster | delorie software privacy |
Copyright © 2004 | Updated Apr 2004 |