strset

String Manipulation Functions

Fills a string with a specific character.

char *strset( char *string1, int character);

string1The string to which to add the character.
characterThe character(s) to add.

Return Values

A pointer to the string filled with the specified character.

Example

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