Share this page

# sscanf

Input-Output Functions

Reads formatted input from a string.

    int sscanf( const char *buffer, const char *format_string, args);

buffer | The target buffer.
format_string | One or more formatting characters.
args | One or more print arguments.

For sscanf details, refer to your C language documentation.

## Return Values

If successful, the function returns the number of items successfully read. This count does not include any ignored fields.

## Example

The following example uses sscanf to read the string sentence and retrieve the first 3 elements from it. It then sends these elements, s1, num_of_years, and s2, in an output message.

Copy code

        char sentence[] = "After 7 years' siege yet Troy walls stand";
        char s1[32], s2[32];
        int num_of_years;
        sscanf(sentence,"%s %d %s", s1, &num_of_years, s2);
        lr_output_message ("Number of years=%d s2=\"%s\"", num_of_years, s2);

    Example: Output:
    Action.c(7): Number of years=7 s2="years'"

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: