Skip to content

Instantly share code, notes, and snippets.

@yifu
Created September 21, 2012 15:30
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 yifu/3762189 to your computer and use it in GitHub Desktop.
Save yifu/3762189 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <unistd.h>
int main()
{
{
char name [1024] = "";
const int result = gethostname( name, sizeof name );
std::cout << "result [" << result << "] name[" << name << "]" << std::endl;
}
{
const long result = gethostid();
std::cout << "result [" << result << "]" << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment