Topic: Standerd library question


Author: John Aldridge <jpsa@jjdash.demon.co.uk>
Date: 1999/07/26
Raw View
In article <Pine.SOL.4.05.9907221337130.8853-100000@titan.cc.wwu.edu>,
GryMor <metke@cc.wwu.edu> writes
>I'm curiouse about what the correct prototype for swprintf should look
>like. The standerd only seems to list it's name...
>
>One compiler has it declared as:
>int swprintf(wchar_t *, size_t, const wchar_t *, ...);

This is correct according to my understanding of the C standard, as
amended by Normative Addendum 1.

Also beware that a compiler with which I'm familiar, and which supplies
the non-conforming

>int swprintf(wchar_t *, const wchar_t *, ...);

also misinterprets "%s" in the format string as expecting a wchar_t*
argument, whereas it should take a char* argument.
--
Cheers,
John
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: kuehl@horn.fmi.uni-konstanz.de (Dietmar Kuehl)
Date: 1999/07/23
Raw View
Hi,
GryMor (metke@cc.wwu.edu) wrote:
: I'm curiouse about what the correct prototype for swprintf should look
: like. The standerd only seems to list it's name...

This is a function inherited by C++ from C. To avoid cnflicts between
the definitions in the two standards, the C++ standard just references
the C functions.

BTW, you might want to consider using 'wostringstream' (from the header
<sstream>) which does the same thing but the C++ style.

: int swprintf(wchar_t *, size_t, const wchar_t *, ...);

According to the reference by P.J.Plauger and Jim Brodie, this the
correct one.

: I thought the second pair was the correct one until I looked and found out
: there isn't a snwprintf in the standerd, and ran into some code using the
: first.

There is no such function in the C standard and thus there is no such
function in the C++ standard.
--
<mailto:dietmar.kuehl@claas-solutions.de>
<http://www.informatik.uni-konstanz.de/~kuehl/>
I am a realistic optimist - that's why I appear to be slightly pessimistic
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: GryMor <metke@cc.wwu.edu>
Date: 1999/07/22
Raw View
I'm curiouse about what the correct prototype for swprintf should look
like. The standerd only seems to list it's name...

One compiler has it declared as:
int swprintf(wchar_t *, size_t, const wchar_t *, ...);
another as:
int swprintf(wchar_t *, const wchar_t *, ...);
with another function
int _snwprintf(wchar_t *, size_t, const wchar_t *, ...);


a third one doesn't define it.

I thought the second pair was the correct one until I looked and found out
there isn't a snwprintf in the standerd, and ran into some code using the
first.

Steve 'GryMor' Metke bani Virtual Adepts metke@cc.wwu.edu \      /\
Goth code 98 uSKija6CaPjaiaaaGbaa54hAMGULv1jnq???b4FOiGa3  \    /  \
d1aab5aaaaaaae0aaTNahhbjvpk3aaasNbqePGnDhaaaacausWA         \  /----\
Reality's just a bunch of bits. Aku Soku Zan                 \/      \
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]