Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

wsprintf or swprintf

888 views
Skip to first unread message

Alex Georgiev

unread,
Aug 25, 1999, 3:00:00 AM8/25/99
to

Does anyone know what is the difference between wsprintf()
and swprintf()? From what I can gather out of MSDN they
_should_ do the exact same thing, and _should_ both work
with UNICODE chars. So I guess I am left wondering why are
there two of them and not one, and also which one should I
by using? Do they handle regular 8 bit char as well?

...or I am asking the wrong group of people on this topic?
Hopefully someone other there deals with UNICODE stuff and
will be able to help me...

--
Alex Georgiev

Todd Osborne

unread,
Aug 26, 1999, 3:00:00 AM8/26/99
to
wsprintf() does NOT handle floating point parameters. Other than that, one
is a CRT function and the other a Win32 implemented API.

Todd

Alex Georgiev <geor...@flop.ENGR.ORST.EDU> wrote in message
news:slrn7s8vsj....@flop.ENGR.ORST.EDU...

Andrew E. Walldorff

unread,
Aug 26, 1999, 3:00:00 AM8/26/99
to
wsprintf also does not handle variable width and precission. For example,

float fVal = 10.1234567899
int cWidth = 10;
int cPrec = 2;

wsprintf( _T( "%*.*f" ), cWidth, cPrec, fVal ); // fails misserably
swprintf( L"%*.*f", cWidth, cPrec, fVal ); // works great

also note the potential differences in the format string.


Todd Osborne wrote in message ...

Todd Osborne

unread,
Aug 26, 1999, 3:00:00 AM8/26/99
to
Very true. I think it is safe to say, use sprintf(), from the CRT. It is
more portable, and more capable.

Todd

Andrew E. Walldorff <an...@rcs-incREMOVE.com> wrote in message
news:37c5...@nebula.superior.net...

Alex Georgiev

unread,
Aug 26, 1999, 3:00:00 AM8/26/99
to

Thanks for the responses! I made up my mind to use swprintf().
I'm using it for some UNICODE stuff, otherwise I would have
just used the regular sprintf().

--
Alex Georgiev

0 new messages