Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6827107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:13:38+00:00 2026-05-26T22:13:38+00:00

Possible Duplicate: C/C++: Passing variable number of arguments around Imagine I have a function

  • 0

Possible Duplicate:
C/C++: Passing variable number of arguments around

Imagine I have a function mySuperDuperPrintFunction that takes a variable number of arguments. This function calls printf (or any other function with a variable number of arguments. Can i somehow pass all, or only some, parameters from the arglist to the other function ? Like

void mySuperDuperPrintFunction(char* text, ...) {

    /*
     * Do some cool stuff with the arglist.
     */

    // Call printf with arguments from the arglist
    printf(text, *someWayToExtractTheArglist());
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:13:39+00:00Added an answer on May 26, 2026 at 10:13 pm

    Yes:

    va_list args;
    va_start(args, text);
    
    vprintf(format_goes_here, args);
    

    You can find info about vprintf here (or check your man pages).

    I’ve done similar for wrapping functions such as write (Unix) and OutputDebugString (Windows) so that I could create a formatted string to pass to them with vsnprintf.

    EDIT: I misunderstood your question. No you can’t, at least not in C. If you want to pass the variable number of arguments on, the function you’re calling must take a va_list argument, just like vprintf does. You can’t pass your va_list onto a function such as printf(const char *fmt,...). This link contains more information on the topic.

    If the function does take a va_list argument, then you can pass arguments from a specific point (ie. you might to skip the first one). Retrieving arguments with va_arg will update the va_list pointer to the next argument, and then when you pass the va_list to the function (such as vprintf), it’ll only be able to retrieve arguments from that point on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: C/C++: Passing variable number of arguments around I need to put all
Possible Duplicate: Passing arbitrary number of parameter to a function in javascript How to
Possible Duplicate: PHP passing parameters via URL I know that if you have a
Possible Duplicate: C++ passing variables in from one Function to the Next. The Program
Possible Duplicate: Passing a Int value to another class I have been trying to
Possible Duplicate: Convert Month Number to Month Name Function in SQL Hi .... how
Possible Duplicate: Passing javascript variable to PHP Hi I wonder if it's possible to
Possible Duplicate: Why passing &error instead of error in Cocoa programming? I have a
Possible Duplicate: How can I pre-set arguments in JavaScript function call? (Partial Function Application)
Possible Duplicate: C#: Passing null to overloaded method - which method is called? Here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.