va_start() in C programmingThe va_start is a macro defined in the stdarg header file in the C Programming languages. The va_start() function is used to initialize the argument list. The argument list is referred to by ap. Initializing the argument list is necessary before using the va_arg() and va_end() functions in the program. The second argument passed in the va_start() function is the last_arg. This argument is also called the fixed argument. This argument is passed in the function that is the argument before the ellipsis. The macros are called in the program before calling the va_arg and va_end in the function. Syntax for using va_start() functionThe declaration for va-start() macro in your program: Return Type in va_start() functionvoid: Since the function does not return any value, the return type used when declaring the va_start() function is void. Parameters Passed in va_start() function
Header file:Since this macro is defined in the stdarg library, thus, it is necessary to include the header file in your program Implementation of va_start() function in C Program:Output: Let us discuss another example of printing the product of a list of numbers. Output: Conclusion: Before implementing the va_arg() function in the your program, it is necessary to implement the va_start() function in your code and end it with va_end() function. Next TopicAscii vs Unicode |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India