Discussion:
wsprintf?
(too old to reply)
David Webber
2004-05-24 14:18:14 UTC
Permalink
Having revisited some old code I am reminded of the existence of

wsprintf().

I vaguely remember from the old 16bit days that there was some
reason to prefer it over the standard C-library function sprintf(),
but I can't for the life of me remember what it was.

Does it have any advantages these days or is it just there for
legacy code?

Dave
--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm
Simon Trew
2004-05-24 14:29:59 UTC
Permalink
Post by David Webber
Having revisited some old code I am reminded of the existence of
wsprintf().
I vaguely remember from the old 16bit days that there was some
reason to prefer it over the standard C-library function sprintf(),
but I can't for the life of me remember what it was.
Does it have any advantages these days or is it just there for
legacy code?
I guess the only advantage (unless there is a significant speed advantage,
which seems unlikely) is that as it is a Windows API, you save the size of
the function in your own object code if you are statically linking the run
time library.

Also, wsprintf takes TCHAR types whereas sprintf is always char.

S.
David Webber
2004-05-24 15:00:00 UTC
Permalink
Post by Simon Trew
wsprintf() vs sprintf()
Does it have any advantages these days or is it just there for
legacy code?
I guess the only advantage (unless there is a significant speed advantage,
which seems unlikely) is that as it is a Windows API, you save the size of
the function in your own object code if you are statically linking the run
time library.
That was my feeling (and I am linking the RTL dynamically ).
Post by Simon Trew
Also, wsprintf takes TCHAR types whereas sprintf is always char.
Yes - sorry I didn't mean to ask about that aspect: I am actually
using _stprintf() - the TCHAR version of sprintf() - with a view
to going over to UNICODE when everyone has forgotten about win98 and
WinME.

[And wsprinf won't handle floating point IIRC or possibly 64bit
integers, both of which I use.]

Dave
--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm
Igor Tandetnik
2004-05-24 22:47:42 UTC
Permalink
Post by David Webber
[And wsprinf won't handle floating point IIRC or possibly 64bit
integers, both of which I use.]
wsprintf handles 64-bit integers fine, but it does not indeed support
floating point.
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
Loading...