title: Compile Error with getaddrinfo
body: <p>I am trying to learn the basics of socket programming and am using some code from a guide I found but I am getting compile errors. The code and errors are shown below </p>
  
  <pre><code>#include &lt;sys/types.h&gt;
  #include &lt;sys/socket.h&gt;
  #include &lt;netdb.h&gt;
  
  #define PORT "21467"
  
  int main(void)
  {
  int status;
  struct addrinfo hints;
  struct addrinfo *servinfo; // will point to the results
  memset(&amp;hints, 0, sizeof hints); // make sure the struct is empty
  
  hints.ai_family = AF_INET; 
  hints.ai_socktype = SOCK_STREAM; // TCP stream sockets
  hints.ai_flags = AI_PASSIVE; // fill in my IP for me
  
  if ((status = getaddrinfo(NULL, PORT, &amp;hints, &amp;servinfo)) != 0) {
      //fprintf(stderr, "getaddrinfo error: %s\n", gai_strerror(status));
      exit(1);
  }
  // servinfo now points to a linked list of 1 or more struct addrinfos
  // ... do everything until you don't need servinfo anymore ....
  freeaddrinfo(servinfo); // free the linked-list
  
  return 0;
  }
  </code></pre>
  
  <p>Compile errors:</p>
  
  <pre><code>server.c: In function 'main':
  server.c:16: warning: incompatible implicit declaration of built-in function 'memset'
  server.c:24: warning: incompatible implicit declaration of built-in function 'exit'
  Undefined                       first referenced
   symbol                             in file
  getaddrinfo                         /var/tmp//ccU0yRDe.o
  freeaddrinfo                        /var/tmp//ccU0yRDe.o
  ld: fatal: Symbol referencing errors. No output written to a.out
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>Any help would be greatly appreciated!</p>