Skip to content

Instantly share code, notes, and snippets.

@favoretti
Created March 22, 2013 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save favoretti/5221652 to your computer and use it in GitHub Desktop.
Save favoretti/5221652 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <unistd.h>
int main(void) {
char host[256];
if (gethostname(host, sizeof(host)) == 0)
host[sizeof(host) - 1] = '\0';
printf("%s\n", host);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment