summaryrefslogtreecommitdiff
path: root/Userland/hostname.cpp
blob: d343b5b55ef57c38ba901e30607a6cd3463c7105 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#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;
}