Hi Lindley,
Would it be possible for you to please confirm / correct me on this small code snippet below? I just want to be reassured i have taken in what you have stated in the comments above and have it right ;-)
This seems to work correctly:
Looking forward to your reply.Code:int wmain () { /* Store IP address as an std::array<T> */ std::array<wchar_t, INET_ADDRSTRLEN> IpBuf; /* IP string to convert to binary form */ std::wstring IpStr = L"192.168.2.1"; SOCKADDR SockAddr; /* Convert to binary form */ if (!::InetPton(AF_INET, &IpStr[0], &SockAddr)) return NULL; /* Convert to readable string form */ if (!::InetNtopW(AF_INET, &SockAddr, &IpBuf[0], INET_ADDRSTRLEN)) return NULL; std::wcout << IpBuf.data() << std::endl; return 0; }
Regards
Dan.




Reply With Quote