title: How to use the "pcap_lookupdev()" in libpcap?
body: <p>The code cant find any device, I want to know what does pcap_lookupdev() do ? thanks</p>
  
  <pre><code>#include &lt;pcap.h&gt;
  int main(int argc, char *argv[])
  {
      pcap_t *handle;
  
      char *dev;// = "eth0";
      char errbuf[PCAP_ERRBUF_SIZE];
      dev = pcap_lookupdev(errbuf);
      if (dev == NULL) {
          fprintf(stderr, "Couldn't find default device: %s\n", errbuf);
          return(2);
      }
      printf("Device: %s\n", dev);
      return(0);
  
      handle = pcap_open_live(dev, BUFSIZ, 1, 1000, errbuf);
      if (handle == NULL) {
          fprintf(stderr, "Couldn't open device %s: %s\n", dev, errbuf);
          return(2);
      }
  
  
  }
  </code></pre>