C programming vscanf stdio.h

int vscanf(const char * restrict format,
va_list arg);

Parameters :
format -This parameter will represent the entry point of the second argument and it also consists of conversion specifier.

arg -Stores the variable to which the data is to be written.

Return type
int-Returns the value of the macro EOF if an input failure occurs before any conversion.Otherwise, the vfscanf function returns the number of input items assigned,which can be fewer than provided for,or even zero, in the event of an early matching failure.

In C programming the <stdio.h> vscanf function is equivalent to scanf function but instead of using ellipsis as the second argument it is replaced by va_list macro (found in <stdarg.h> header ).A code example is given below.

Link : C scanf stdio.h

Code example

void func(char* format , …)
int ret;

va_list arg ;

va_start(arg , format);

printf(“Enter any string:”);

ret=vscanf(format , arg);

printf(“\nret=%d” , ret);

va_end( arg );

int main( )
char str[20];

func( “%s” , str);

printf(“\nstr=%s” , str);

getchar( );
return 0 ;


Enter any string:Any string
str=Any string

As you can see calling ‘vscanf’ is same as calling ‘scanf’ except the variable to which the inputted data is to be written is stored in va_list.

Related links

->C vfscanf stdio.h

->C vsscanf stdio.h

->C sscanf stdio.h

->C fscanf