fdds_sscanf - retrieve values from a character string


SYNOPSIS

#include <fdds.h> (fixed-format sources)
#include <f90dds.h> (free-format sources)

integer function fdds_sscanf(str, fmt, ...)

character*(*) str
character*(*) fmt

DESCRIPTION

fdds_sscanf retrieves values from a character string. It is controlled by a format string and optional arguments. Processing begins at the beginning of the character string. Characters are matched and converted, as specified by the ANSI C standard for the stdio scanf function. The current position is advanced as the format is processed. The function returns the number of arguments converted and assigned. It returns EOF, if conversion fails prior to the first assignment.

fmt and optional arguments control the processing of definition values. The rules correspond to the scanf function in the ANSI C standard.

Format strings MUST be terminated with a null character ('\0').

The following table summarizes conversion specifiers recognized within fmt, but see the "C" manual for more detail.

fmt                     modifiers
char      Data type   h     l      L          *         I/O type
----      ---------   --------------------------------  --------------------
 u        integer     short long   longlong   suppress  unsigned
 d        integer     short long   longlong   suppress  decimal
 o        integer     short long   longlong   suppress  octal
 x        integer     short long   longlong   suppress  hexadecimal
 i        integer     short long   longlong   suppress  dec,oct,hex
 n        integer     short long   longlong   suppress  (returns # characters)
 c        characters  NA    NA     NA         suppress  (reads spaces also)
 s        string      NA    NA     NA         suppress  (skips initial spaces)
 p        pointer     NA    NA     NA         suppress
 e, f, g  real        NA    double longdouble suppress
 [...]    character   NA    NA     NA         suppress
 [^...]   character   NA    NA     NA         suppress
 %        NA          NA    NA     NA         NA        (literal "%")
    
fdds_sscanf pads trailing blanks or truncates strings as needed during '%c', '%s' and '%[...]' conversion. Unlike "C", the maximum field width is not required to prevent string overflow.

EXAMPLES

!     default "alpha" to 3.14, override if defined
      n = 0
      beta = ' '
      alpha = 3.14
      ier = fdds_sscanf(card, '%f %s %d\0', alpha, beta, n)
    

SEE ALSO

fdds_scanf Scanf DDS dictionary definitions
    

AUTHOR

Jerry Ehlers, EPTG (June, 2009)