vsscanf_s, vswscanf_s
Go Up to stdio.h Index
Header File
stdio.h
Category
Formatted input/output functions
Prototype
int vsscanf_s(const char * restrict s, const char * restrict format, va_list arg);
int vswscanf_s(const wchar_t * restrict s, const wchar_t * restrict format, va_list arg);
Description
Replaces vsscanf adding security enhancements.
vsscanf_s is equivalent to sscanf_s, swscanf_s with the argument list replaced by arg.
vsscanf_s does not call the va_end macro.
Return Value
vsscanf_s returns the number of input fields successfully scanned, converted, and stored; the return value does not include scanned fields that were not stored. If no fields were stored, the return value is zero. In case of an input error, vsscanf_s returns the value of the macro EOF.
Example
#include <stdio.h> #include <stdarg.h> char buffer[80] = "30 90.0 abc"; int vssf(char *fmt, ...) { va_list argptr; int cnt; fflush(stdin); va_start(argptr, fmt); cnt = vsscanf_s(buffer, fmt, argptr); va_end(argptr); return(cnt); } int main(void) { int inumber; float fnumber; char string[80]; vssf("%d %f %s", &inumber, &fnumber, string); printf("%d %f %s\n", inumber, fnumber, string); return 0; }
Portability
POSIX | Win32 | ANSI C | ANSI C++ |
---|---|---|---|
+ |
+ |
+ |