Hostname: Difference between revisions
Content added Content deleted
m (→{{header|Icon}} and {{header|Unicon}}: -workswith) |
|||
Line 39: | Line 39: | ||
{{works with|POSIX|.1}} |
{{works with|POSIX|.1}} |
||
<lang c>#include < |
<lang c>#include <stdlib.h> |
||
#include <stdio.h> |
|||
#include <limits.h> |
|||
#include <unistd.h> |
#include <unistd.h> |
||
int main() |
int main(void) |
||
{ |
{ |
||
char name[_POSIX_HOST_NAME_MAX + 1]; |
|||
return gethostname(name, sizeof name) == -1 || printf("Hostname: %s\n", name) < 0 ? EXIT_FAILURE : EXIT_SUCCESS; |
|||
gethostname(name, _POSIX_HOST_NAME_MAX+1); |
|||
return 0; |
|||
}</lang> |
}</lang> |
||