cpp-cheat/posix/gethostname.c
2016-02-27 10:51:55 +01:00

20 lines
362 B
C

/*
# gethostname
Copies name of current host on given string:
int gethostname(char* hostname, int namelength);
Name is truncated to namelength if too large
*/
#include "common.h"
int main() {
const int namelength = 256;
char hostname[namelength];
gethostname(hostname, namelength);
puts(hostname);
return EXIT_SUCCESS;
}