problem with vsprintf

Discussion in 'C' started by rajanandhini, Jun 12, 2007.

  1. rajanandhini

    rajanandhini New Member

    Joined:
    Jun 12, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    When I try to compile the following code, I get an additional message from the buffer.

    The code that we use has,
    buf[0] = '\0';
    va_start(va, fmt);
    vsprintf(buf, fmt, va);
    va_end(va);

    len = fprintf(work,"%s",buf);

    The buffer should only contain the content of fmt. But, it also contains the text "parent information" along with the content of fmt. i.e, if the value of fmt is "hi", the value of buf should also be "hi". But the actual value that we get is, "parent informationhi".

    Please help.

    Thanks,

    nan
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    You don't give enough definition information. Please read the "Before you post a query" thread and learn to use code tags.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice