Share this page

# struct

Groups together common variables (see union). The structure name is optional and not needed if the structure variables are defined. Inside it can contain any number of variables separated by semicolons. At the end, structure-variables defines the actual names of the individual structures. Multiple structures can be defined by separating the variable names with commas. If no structure variables are given, no variables are created. Structure-variables can be defined separately by specifying: To access a variable in the structure, you must use a record selector.

Copy code

    struct<i>structure-name</i> {
    <i>variables</i>,...
    } <i>structure-variables</i>,...;

## Example

The following example uses a struct called about_app. An instance of this structure, a, is defined and used in the Actions function.

Copy code

        struct about_app {
            char *version;
            int field1;
            int field2;
        };
    // Global scope
        struct about_app a;
        a.field1 = 12;
        a.field2 = 13;
    // Set all fields to 0
        memset(&a, 0, sizeof(struct about_app));
    // Display field values (0)
        lr_output_message ("After memset field1=%d field2=%d", a.field1, a.field2);
        a.version = "app version 1.0";
        a.field1 = 5;
        a.field2 = 6;
        lr_output_message ("Now, field1=%d field2=%d", a.field1, a.field2);

    Example: Output:
    Action.c(18): After memset field1=0 field2=0
    Action.c(23): Now, field1=5 field2=6

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: