ladybird/Userland/hostname.cpp

20 lines
378 B
C++
Raw Normal View History

#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
2018-10-26 09:54:29 +02:00
int main(int argc, char** argv)
2018-10-26 09:54:29 +02:00
{
(void) argc;
(void) argv;
2018-10-26 09:54:29 +02:00
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;
}