This shows you the differences between two versions of the page.
— |
c:stdio.h:vscanf [2024/02/16 01:05] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{keywords>wiki library source code example reference}} | ||
+ | ====== vscanf ====== | ||
+ | <code c> | ||
+ | int vscanf(char * restrict format, va_list arg_ptr); | ||
+ | </code> | ||
+ | === description === | ||
+ | The functions vscanf(), vfscanf(), and vsscanf() are functionally equivalent to scanf(), fscanf(), and sscanf(), respectively, except that the argument list has been replaced by a pointer to a list of arguments. This pointer must be of type va_list, which is defined in the header . | ||
+ | |||
+ | ===== example ===== | ||
+ | <code c> | ||
+ | #include <stdio.h> | ||
+ | #include <stdarg.h> | ||
+ | |||
+ | void get_message(char *format, ...) | ||
+ | { | ||
+ | va_list ptr; | ||
+ | |||
+ | va_start(ptr, format); | ||
+ | |||
+ | vscanf(format, ptr); | ||
+ | |||
+ | va_end(ptr); | ||
+ | } | ||
+ | |||
+ | int main(void) | ||
+ | { | ||
+ | |||
+ | int i; | ||
+ | printf("integer:"); | ||
+ | get_message(" %d ", &i); | ||
+ | |||
+ | printf("%d", i); | ||
+ | |||
+ | return 0; | ||
+ | } | ||
+ | </code> |