ladybird/Userland/hostname.cpp
2019-06-07 11:49:31 +02:00

18 lines
375 B
C++

#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char** argv)
{
(void)argc;
(void)argv;
char buffer[HOST_NAME_MAX];
int rc = gethostname(buffer, sizeof(buffer));
if (rc < 0) {
printf("gethostname() error: %s\n", strerror(errno));
return 1;
}
printf("%s\n", buffer);
return 0;
}