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