How would one output your IP and hostname?
This is a discussion on Outputting your IP and hostname within the C++ Programming forums, part of the General Programming Boards category; How would one output your IP and hostname?...
How would one output your IP and hostname?
cout << "127.0.0.1 localhost" << endl;Originally posted by Nakeerb
How would one output your IP and hostname?
hello, internet!
he speaks the truth.Originally posted by moi
cout << "127.0.0.1 localhost" << endl;
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
I meant using Winsock
That's the loopback address on any computer.
Code:char * local_host_info(char buffer[]) { int index = 0; const int max = 200; char local[max]; hostent * find; int result; buffer[0] = 0; strcat( buffer, "Local host name: " ); result = gethostname( local, max ); find = gethostbyname( local ); if( !find || result == SOCKET_ERROR ) { strcat( buffer, "Information not Available.\n" ); return buffer; } strcat( buffer, local ); while( find->h_addr_list[ index ] ) { strcat( buffer, "\n" ); strcat( buffer, inet_ntoa( *(in_addr*)find->h_addr_list[ index++ ] ) ); } return strcat( buffer, "\n\n\n"); } int main() { char buff[256] //...initialize winsock... printf("My info \n\n%s", local_host_info( buff )); return 0; }
Code:int main(void){srand(time(0));for(double l=rand(),l0=0,l00=0;;l0+=0.1){for(double l000=0;l000 <1;l000+=.001,l+=((double)rand()/RAND_MAX)/0x64,l00+=((sin(l*0x8*atan(l0)*l000-(l0*0x8*atan (l)))*0.5)+0.5)){l00-=floor(l00);for(size_t l0000=0,l00000=(size_t)(0x50*(l00));l0000<l00000;++l0000 )putchar(0x20);putchar(0x61+(int)((double)rand()/RAND_MAX*0x1a));putchar('\n');}}return 0;}