title: converting string to network address
body: <p>I have a Visual Studio 2008 C++ application where I would like to convert an IP address from a wide-character string in dotted-quad notation to an address (similar to <code>inet_aton</code>);</p>
  
  <p>I'm doing this:</p>
  
  <pre><code>DWORD StringToAddress( const std::wstring&amp; address )
  {
      BYTE a = 0, b = 0, c = 0, d = 0;
      swscanf( address.c_str(), L"%u.%u.%u.%u", &amp;a, &amp;b, &amp;c, &amp;d );
      return d &lt;&lt; 24 | c &lt;&lt; 16 | b &lt;&lt; 8 | a;
  }
  </code></pre>
  
  <p>Unfortunately, when I give an address like <code>169.254.255.255</code> the third quad comes out of the <code>swscanf</code> as <code>0</code> and not <code>255</code>.</p>
  
  <p>Am I doing something wrong? Is there a good way to fix this?</p>
  
  <p>Thanks,
  PaulH</p>