SSCANF

Purpose:

Converts an input string by applying a C/C++ style format control string.

Syntax:

SSCANF("string", "control", var1, var2, ..., varN)

"string"

-

The input string. The string to be converted by applying the control string,

"control"

-

Format control string. Conforms to C/C++ language printf specifications. Control strings may contain ordinary characters, escape sequences, and format specifications. The ordinary characters are copied to the output in order of their appearance. Escape sequences are introduced by a backslash (). Format specifications in the control string are introduced by a percent sign (%), and are matched to the specified arguments in order. If there are more arguments than there are format specifications, the extra arguments are ignored. See SPRINTF for further details.

varN

-

Optional. One or more variables. Each variable is set to the result of the string conversion. If no variables are specified, sscanf returns the result of the conversion.

Returns:

The result of the conversion (a string or scalar) if no variables are specified else the number of variables successfully processed..

Example:

sscanf("123", "%d")

 

returns the integer 123:

Example:

sscanf("123", "%g")

 

returns the real 123.0:

Example:

a = b = c = 0;

sscanf("10 Units 0xff", "%d %s %x", a, b, c);

 

returns 3 indicating that 3 variables were successfully converted. The variables are set as follows:

 

a == 10

b == "Units"

c == 255

Example:

a = 0;

sscanf("123", "%g", a);

 

returns 1 and a == 123:

Example:

a = 0;

sscanf("alpha", "%g", a);

 

returns 0 indicating the string could not be converted using the "%g" format control.

Remarks:

SSCANF uses a control string in the format of the C/C++ language sscanf and sprintf functions. For more detailed information, see a C/C++ language function reference.

See Also:

NUMSTR

PRINTF

SPRINTF