Home >>C String functions >C strset() function

C strset() function

C strset() function

C strset() function set all the characters in a string to given character.

Syntax:
Strset(str,char)

Note:- Here str is given string.

Parameters:-

It takes string and character as parameter.

Return type:-

It returns modified string.

Example-1

#include <stdio.h>
#include <string.h>
int main()
{
   char str[20] = "String";
   printf("Original string is : %s", str);
   printf("Test string after strset() : %s",strset(str,'#'));
   printf("After string set: %s",str);
   return 0;
}

Output:
original string is: string
Test string after strset():######

No Sidebar ads