Share this page

# Example: strset

The following example uses strset to fill the string str with `x' characters.

Although the length of the character array is 16, the previous call to strcpy appends a null character to the end of "Fill me in", which is 10 characters long. Since strset sets characters until reaching a null byte, only 10 `x' characters are written.

        #include <string.h>

        char str[16];

    // strcpy appends a NULL here

        strcpy(str, "Fill me in");
        lr_output_message ("Before strset str=%s", str);
        strset(str, 'x');
        lr_output_message ("After strset str=%s", str);

    Example: Output:
    Action.c(6): Before strset str=Fill me in
    Action.c(8): After strset str=xxxxxxxxxx

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