strnset
Sets a specified number of characters in a string to a given character
#include <string.h> char *strnset ( char *s1, int fill, size_t len);
The address of the original string s1 is returned.
strnset fills the string s1 with the value of the argument fill, converted to be a character value. When the value of len is greater than the length of the string, the entire string is filled. Otherwise, that number of characters at the start of the string is set to the fill character.
#include <string.h> char source[ ] = {"A sample STRING"}; main () { printf ("%s\n", source); printf ("%s\n", strnset (source, `=’, 100) ); printf ("%s\n", strnset (source, `*’, 7) ); }
produces the following:
A sample STRING =============== *******========