VMS Help
CRTL, sscanf
*Conan The Librarian
|
Reads input from a character string in memory, interpreting it
according to the format specification.
Format
#include <stdio.h>
int sscanf (const char *str, const char *format_spec, . . . );
str
The address of the character string that provides the input text
to sscanf.
format_spec
A pointer to a character string that contains the format
specification.
. . .
Optional expressions whose resultant types correspond to
conversion specifications given in the format specification.
If no conversion specifications are given, you can omit the input
pointers. Otherwise, the function calls must have at least as
many input pointers as there are conversion specifications, and
the conversion specifications must match the types of the input
pointers.
Conversion specifications are matched to input sources in left-
to-right order. Excess input pointers, if any, are ignored.
The following is an example of a conversion specification:
main ()
{
char str[] = "4 17";
int temp,
temp2;
sscanf(str, "%d %d", &temp, &temp2);
printf("The answers are %d and %d.", temp, temp2);
}
This example produces the following output:
$ RUN EXAMPLE
The answers are 4 and 17.
x The number of successfully matched and
assigned input items.
EOF Indicates that a read error occurred before
any conversion. The function sets errno. For a
list of the values set by this function, see
fscanf.