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:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }