Strnset :
strnset(str,ch,n) set the first n character of str to ch. quits when the first null character is found. Returns a pointer to str.
Syntax :
char *strnset( const char *str,char ch ,int n);
C – STRING EXAMPLE PROGRAM :
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#include<stdio.h> #include<conio.h> #include<string.h> int main() { char *str=”I LIKE C PROGRAMMING”; clrscr(); printf(“\nBefore : \n str : %s\n”,str); printf(“strnset(str,’@’,6):%s\n, strnset(str,’@’,6)); printf(“\n After :\n str : %s\n”,str); getch(); return 0; } |
Output :
Before :
str : I LIKE C PROGRAMMING strnset(str,’@’,6)=@@@@@@ C PROGRAMMING After : str : @@@@@@ C PROGRAMMING |