I have a function
void func(int x, char *str, ...)
{
...
}
I am invoking it as follows:
func(1, "1", "2", "3");
How can I print the values of all the extra arguments (2, 3) in function?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
From the man page of
STDARGabout the use ofva_argto get the next argument:Hence, unless you want random errors to creep in, you should know the number of arguments beforehand.
Even so, if you want to throw caution to the winds, you could try:
With,
I got the output,
If it satisfies your purpose, you could pick out the required number of arguments from this output.