* Susan Rice:
> How can I rewrite this code to avoid the possibility of a
> buffer overflow?
>
> sprintf(errbuf, "%s\nError is: %u: %s\n", errmsg, dwErrCode, s );
>
> Here:
> errmsg = a string
> dwErrCode = a number
> s = a string
> I do have value 'errbuflen' = length of buffer 'errbuf'.
> I'm just not using it.
> Is there any easy way? Or is there only the hard way?
std:

stringstream stream;
stream << errmsg << "\nError is: " << dwErrCode << ": " << s << "\n";
// Do something with stream.str()
Btw., Hungarian notation like the prefix 'dw' is likely to cause you all
kinds of trouble, and reduces readability, without conferring /any/
advantage with modern tools.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?