- strset( ) function sets all the characters in a string to given character. Syntax for strset( ) function is given below.
char *strset(char *string, int c);
- strset( ) function is non standard function which may not available in standard library in C.
Example program for strset() function in C:
- In this program, all characters of the string “Test String” is set to “#” using strset( ) function and output is displayed as “###########”.
#include<stdio.h> #include<string.h> int main() { char str[20] = "Test 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 : Test String
Test string after strset() : ###########
|
0 comments:
Post a Comment