C Programming - Variable Number of Arguments - Discussion

Discussion Forum : Variable Number of Arguments - True / False Questions (Q.No. 5)
5.
A function that receives variable number of arguments should use va_arg() to extract the last argument from the variable argument list.
True
False
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
7 comments Page 1 of 1.

Shivani Singh said:   5 years ago
I am not understanding this, please explain.
(1)

Zaid said:   8 years ago
To extract the last argument we still need va_arg(), va_end() cleans up the list, it doesn't extract the last argument for us.

Subra said:   9 years ago
To access any elements we should av_arg().

va_end will return void so va_end is not used to extract last elements instead it used to destroy the va_list type ptr we created.

Chandu said:   1 decade ago
Can any one explain this concept with one practical example please?

Sumit said:   1 decade ago
The va_end() function destroys the variable argument list pointer p, rendering it invalid unless va_start() is called again.

So to access last argument va_arg is used before va_end.
I think so.

Champ said:   1 decade ago
Use va_end() for that.

The va_end() function destroys the variable argument list pointer p, rendering it invalid unless va_start() is called again.

Raj said:   1 decade ago
Can anyone pls tell how to extract the last arguement from the variable argument list?

Post your comments here:

Your comments will be displayed after verification.