View Single Post
Old Jul 26th, 2007, 11:45 AM   #5
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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".
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote