The strnset() function is a builtin function in C and it sets the first n characters of a string to a given character. If n is greater than the length of string, the length of string is used in place of n.
char *strnset(const char *str, char ch, int n);
- str: This is the original string in which some character are replaced by a given character.
- ch: ch represents the given character.
- n: n represents the number of character which is replaced by the given character.
Return Value: It returns the modified string obtained after replacing the first characters of the given string str.
Below programs illustrate the strnset() function in C:
Original String: GeeksforGeeks Modified String: *****forGeeks
Original String: Computer Science Modified String: *****ter Science
Note: The strnset() function is not a part of the standard C library and thus might not run on the online compilers.
- arc function in C
- iswcntrl() function in C/C++
- iswupper() function in C/C++
- putwchar() function in C/C++
- vswscanf() Function in C/C++
- vwprintf() function in C/C++
- iswlower() function in C/C++
- Address of a function in C or C++
- towctrans() function in C/C++
- wmemcmp() function in C/C++
- wcstoul() function in C/C++
- wmemchr() function in C/C++
- vswprintf() function in C/C++
- wcrtomb() function in C/C++
- wcsncmp() function in C/C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.