title: How to use getaddrinfo()?
body: <p>Im trying to make a simple program that takes in a string like www.google.com and returns the ip address...</p>
  
  <p>What i have so far: </p>
  
  <pre><code>char* hostname = new char[www.size()+1];
  std::copy(www.begin(), www.end(), hostname);
  hostname[www.size()] = '\0';
  
  struct addrinfo new_addr, *res;
  
  getaddrinfo(www.c_str(), SERVICE.c_str(), &amp;new_addr, &amp;res);
  
  
  
  cout &lt;&lt; new_addr.ai_addr;
  </code></pre>
  
  <p>What are the 3rd of 4th parameters supposed to do? Does the getaddrinfo function modify the new_addr structure or what? I dont really understand the msdn documentation. After the hostname is resolved I want to connect a socket to it. </p>