This does what I want, namely, gives a correct string.
But I don't quite understand how it works (functions with variable argument lists in general). The compiler can't be simply giving pointers to the 4 bytes in DW to Sprintf() because Sprintf() can't know that I want only bytes. So what's the compiler doing?
#define DW (pDnsRecord->Data.A.IpAddress) // a DWORD, network order Sprintf(psz, L"%u.%u.%u.%u", *((BYTE*)&DW) , *((BYTE*)&DW+1) , *((BYTE*)&DW+2) , *((BYTE*)&DW+3)); #undef DW