http://www.cplusplus.com/reference/c...ib/getenv.html
For Linux:
#include <iostream>
using namespace std;
int main (void)
{
char *x = getenv("HOSTNAME");
cout << x << endl;
return 0;
}
For Windows... the environment variable you want is "COMPUTERNAME".