I've this code made in c++ to connect to a server but every time I try "gethostbyname" the value is null(or optimized away and not available).
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
cout << "WSAStartup failed.\n";
system("pause");
return 1;
}
hostent *host = gethostbyname("www.example.com");
I've tried hostent as volatile but still gives null. Is there any other way to make this work? I've tried too Optimization disabled but keeps giving null.