//---------------------------------------------------------------- // showhost.cpp // // This program is just for testing of our 'myexec.s' demo. // // programmer: ALLAN CRUSE // written on: 10 SEP 2004 //---------------------------------------------------------------- #include // for printf() #include // for gethostname() #include // for getenv() int main( void ) { //----------------------------------------------- // obtain this station's hostname and display it // (information is in '/etc/sysconfig/network') //----------------------------------------------- char hostname[ 64 ]; gethostname( hostname, 64 ); printf( "\nhostname is \'%s\' \n", hostname ); //------------------------------------------------ // now show hostname from the current environment //------------------------------------------------ printf( "HOSTNAME=%s \n\n", getenv( "HOSTNAME" ) ); }