title: Multiple default gateways getting
body: <p>i have a program in <strong>C++</strong> which is getting <strong>Default Gateway</strong>, so it works okay <strong>until I try it on PC witch has few default gateways.</strong> Here is my code: </p>
  
  <pre><code>DWORD Err,AdapterInfoSize =0;
      PIP_ADAPTER_INFO pAdapterInfo, pAdapt;
      if ((Err = GetAdaptersInfo(NULL, &amp;AdapterInfoSize)) != 0) {
          if (Err != ERROR_BUFFER_OVERFLOW){
              std::cout&lt;&lt;"ERROR S05\n";
              cin.ignore();
          }
      }
      if ((pAdapterInfo = (PIP_ADAPTER_INFO) GlobalAlloc(GPTR, AdapterInfoSize)) == NULL) {
          std::cout&lt;&lt;"ERROR S06\n";
          cin.ignore();
      }
      if ((Err = GetAdaptersInfo(pAdapterInfo, &amp;AdapterInfoSize)) != 0) {
          std::cout&lt;&lt;"ERROR S07\n";
          cin.ignore();
      }
      pAdapt = pAdapterInfo;
      while (pAdapt){
          dfltgw = pAdapt-&gt;GatewayList.IpAddress.String;
          break;
      }
      pAdapt = pAdapterInfo;
      cout &lt;&lt; endl &lt;&lt; "DEFAULT GATEWAY: " &lt;&lt; dfltgw &lt;&lt; endl;
  </code></pre>
  
  <p>On <strong>PC</strong> where I have a <strong>virtual network of VirtualBox</strong> I always get output: <strong>0.0.0.0</strong> and on my PC where I have 1 Default Gateway I get the right IP.</p>
  
  <p>So how can I fix it?</p>