Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <winsock2.h>
- #include <Ws2tcpip.h>
- #pragma comment(lib,"Ws2_32.lib")
- using namespace std;
- int main() {
- WSADATA wd;
- WSAStartup(MAKEWORD(2, 2), &wd);
- char host[1024];
- string inputAddress;
- struct sockaddr_in socketAddress;
- cout << "IP to Hostname resolve :\n";
- cin >> inputAddress;
- socketAddress.sin_family = AF_INET;
- inet_pton(AF_INET, inputAddress.c_str(), &(socketAddress.sin_addr));
- getnameinfo((struct sockaddr *)&socketAddress, sizeof(socketAddress), host, 1024, NULL, NULL, 0);
- cout << "Hostname: "<< host <<"\n";
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement