In C, strset() fills every character of a writable C-string with one byte and leaves the ending '\0' in place. It is an extension and is not part of ISO C.
You pass the string and the fill byte. Both are required. Prefer a portable loop or memset when you need standard C.
Syntax
Pass a writable string and the fill character. Start with this call.
C
strset(word, '*');
Call
What it does
strset(word, '*')
Replaces every character in word with '*', and keeps the ending '\0'.
Not ISO C. Never pass a string literal. A portable loop or memset works everywhere.
Library declarations
C
char *strset(char *str, int c);
Parameters
Parameter
Description
str
Required. A writable C-string. Do not pass a string literal.
c
Required. The fill byte, often a character in single quotes.
Return Value
Return Value
Description
str pointer
The same pointer you passed in.
C Examples
Example 1 — Fill With Asterisks
Replace every visible character in a writable array. Same idea as extension strset, done with a portable loop.