vsscanf
Scans and formats input from a stream.
Defined in header <stdarg.h>
Syntax
#include <stdarg.h>
int vsscanf(const char *buffer, const char *format, vajist arglist);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ |
Remarks
Available on UNIX system V.
The V...scanf functions are known as alternate entry points for the ...scanf functions. They behave exactly like their ...scanf counterparts, but they accept a pointer to a list of arguments instead of an argument list.
See scanf for details
vsscanf scans a series of input fields, one character at a time,
on format specifiers.
| from stream. Then each field is formatted | to | |
| reading format specifier passed to vsscanf in the format string pointed to by format. Finally, vsscanf stores the formatted input at an address passed to it as an argument following format. There must be the same number of format specifiers and addresses as there are input fields. | a | according a |
vsscanf might stop scanning a particular field before it reaches the normal end-of-field (whitespace) character, or it might terminate entirely, for a number of reasons. See scanf for a discussion of possible causes.
Return value
vsscanf 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 0.
If vsscanf attempts to read at end-of-string, the return value is EOF.
See also
Example
#include <stdio.h>
#include <conio.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 (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;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/stdarg.h/vsscanf/
· short form /3.1/vsscanf/