title: C - getaddrinfo()
body: <p>Can someone help me to get the IPs of google.com?<br><br>
  I can't find any good resource on this.<br>
  Most tutorials on C network programming create a client socket and a server socket on the same computer. (I don't know in which situation that would make sense) <br>
  And none of the codes on beej.us worked for me. <br></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;sys/socket.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;netdb.h&gt;
  
  int main(void)
  {
      struct addrinfo* res = NULL;
      getaddrinfo("google.com", "443", 0, &amp;res);
  
      struct addrinfo* i;
  
      for(i=res; i!=0; res=res-&gt;ai_next)
      {
          printf("%s\n", res-&gt;ai_addr-&gt;sa_data);
      }
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>�
  �
  �
  ���$u
  ���$u
  ���$u
  ���"u
  ���"u
  ���"u
  ��� u
  ��� u
  ��� u
  ���&amp;u
  ���&amp;u
  ���&amp;u
  Segmentation fault
  </code></pre>