C Tutorial/stdio.h/vscanf vfscanf vsscanf


Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Creation of dynamic property PPDStack::$accum is deprecated in /var/www/cppe.ru/www/includes/parser/Preprocessor_DOM.php on line 803

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/vendor/mediawiki/at-ease/src/Functions.php on line 48
Материал из C\C++ эксперт
Перейти к: навигация, поиск

vscanf, vfscanf, and vsscanf

Item Value Header file stdarg.h stdio.h Declaration int vscanf(char * restrict format, va_list arg_ptr); int vfscanf(FILE * restrict stream, const char * restrict format,va_list arg_ptr); int vsscanf(char * restrict buf, const char * restrict format, va_list arg_ptr);

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 <stdarg.h>.


#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;
  }