title: Problems with gethostbyname c++
body: <p>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).</p>
  
  <pre><code>WSADATA wsaData;
  if (WSAStartup(MAKEWORD(2, 2), &amp;wsaData) != 0) {
      cout &lt;&lt; "WSAStartup failed.\n";
      system("pause");
      return 1;
  }
  hostent *host = gethostbyname("www.example.com");
  </code></pre>
  
  <p>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.</p>