S
Sekhar
While using variable arguments we have to initialize variable argument
like
va_start( arg_ptr, prevParam );
Can any body explain what is the significance of second
parameter(prevParam) while initialization of variable arguments.
Following is an extract from msdn, i am not able to understand the
relevance of first parameter in the function Average() and how it is
used while initialization of variable arguments.
int main( void )
{
printf( "Average is: %d\n", average( 2, 3, 4, -1 ) );
}
int average( int first, ... )
{
int count = 0, sum = 0, i = first;
va_list marker;
va_start( marker, first ); /* Initialize variable arguments. */
while( i != -1 )
{
sum += i;
count++;
i = va_arg( marker, int);
}
va_end( marker ); /* Reset variable arguments. */
return( sum ? (sum / count) : 0 );
}
like
va_start( arg_ptr, prevParam );
Can any body explain what is the significance of second
parameter(prevParam) while initialization of variable arguments.
Following is an extract from msdn, i am not able to understand the
relevance of first parameter in the function Average() and how it is
used while initialization of variable arguments.
int main( void )
{
printf( "Average is: %d\n", average( 2, 3, 4, -1 ) );
}
int average( int first, ... )
{
int count = 0, sum = 0, i = first;
va_list marker;
va_start( marker, first ); /* Initialize variable arguments. */
while( i != -1 )
{
sum += i;
count++;
i = va_arg( marker, int);
}
va_end( marker ); /* Reset variable arguments. */
return( sum ? (sum / count) : 0 );
}