CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2005
    Posts
    10

    Question 'vararg' functions??

    Hey All -

    I want to send a string as a formated string to a function... meaning

    say the function name is LOG

    so i want to do a function call as

    LOG("The integer valu is %d",iValue);

    this string shd go as "The integer valu is 10", if iValue is 10....

    i tried declaring the function as

    void LOGGER(char *chpLog, ...) // (i tried to use the eclips operator)
    {
    -------
    }


    but the value of chpLog is comming as "The integer valu is %d"... do any one know how to tackle this ??


    I know we can format the string using sprintf or CString::Format()..... but all these requires another variable and memory ...which i dont want to spend...!!

    can it be solved using 'vararg' functions??... does any one know its implementation????

  2. #2
    Join Date
    Jun 2002
    Posts
    1,417

    Re: 'vararg' functions??

    your function declaration is correct, but you need to use vargs. see the example for vsprintf .

  3. #3
    Join Date
    Jul 2005
    Posts
    10

    Re: 'vararg' functions??

    super dude... its worked fine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured