Re: snwprintf - standard

Discussion in 'C Programming' started by Googler, Aug 22, 2003.

  1. Googler

    Googler Guest

    wrote:
    > Googler <> wrote:
    >>
    >> snwprintf(s,5,L"Hello");
    >>
    >> I know the return value should indicate error. (eg. -1)
    >> However, what is the state of the buffer 's' after the call.
    >> Does the standard say anything about this ?
    >>
    >> Should there be s[0] = 0;

    >
    > No.
    >
    >> Should s contain 'H','e','l','l','\0' (L omitted for brevity)

    >
    > Yes.
    >
    >> Likewise for say
    >> snwprintf(s,4,L"Hello"); /* This isn't a border case like the
    >> earlier but an error all the same */

    >
    > s should contain 'H','e','l','\0' (L again omitted).


    The standard for swprintf doesn't seem to be very clear about the
    state of the buffer when -1 is returned.
    Unlike snprintf, where it's very clear.

    The behaviour you say above seems to be written clearly in snprintf
    i.e. Hell\0 & Hel\0.
    However, the standard doesn't say anything like this for swprintf.

    So can I assume that this is true for swprintf also ?


    --
    Ce message a ete poste via la plateforme Web club-Internet.fr
    This message has been posted by the Web platform club-Internet.fr

    http://forums.club-internet.fr/
    Googler, Aug 22, 2003
    #1
    1. Advertising

  2. Googler

    Guest

    Googler <> wrote:
    >
    > The standard for swprintf doesn't seem to be very clear about the
    > state of the buffer when -1 is returned.
    > Unlike snprintf, where it's very clear.


    Although terser than snprintf, it seems perfectly clear to me -- the
    output is written into the buffer until it's finished or n-1 characters
    have been written, whichever comes first, then a null byte is appended.

    -Larry Jones

    You should see me when I lose in real life! -- Calvin
    , Aug 23, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Googler

    snwprintf - standard

    Googler, Aug 22, 2003, in forum: C Programming
    Replies:
    1
    Views:
    3,356
    Sven Semmler
    Aug 22, 2003
  2. Googler

    snwprintf - standard

    Googler, Aug 22, 2003, in forum: C Programming
    Replies:
    2
    Views:
    767
    Michael B Allen
    Aug 22, 2003
  3. Googler

    snwprintf - standard

    Googler, Aug 22, 2003, in forum: C Programming
    Replies:
    1
    Views:
    447
    Michael B Allen
    Aug 23, 2003
  4. steve.leach

    How standard is the standard library?

    steve.leach, Apr 18, 2005, in forum: Python
    Replies:
    1
    Views:
    388
    Christos TZOTZIOY Georgiou
    Apr 18, 2005
  5. funkyj
    Replies:
    5
    Views:
    1,122
    funkyj
    Jan 20, 2006
Loading...

Share This Page