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