STRNSET() Function – C Program

In previous C Language Program post we had discussed about  Compare String and STRCAM Function and STRCAT Function and STRLEN Function and STRCPY Function and STRNCAT Function and STRNCPY Function and STRREV Function and STRUPR Function and STRLWR Function and STRSET Function.

STRNSET() Function – C Program

Write a C Program to sets some portion of the character of string to given character.

STRNSET() Function – The STRNSET() Function used to sets some portion of  character of string to given character in C Program.

The Syntax of STRNSET() Function :

strnset(str1,  ‘ * ‘, 5) –  First 5  character of string str1 replaced by character ‘ * ‘.

Example of STRNSET() Function C Program

#include<stdio.h>
#include<string.h>
int main()
{
 
char str[100];
 
printf("Please, Enter the String = ");
gets(str);
 
printf(" \n The String after strset is = %s",strlnwr(str, '*', 5));
 
return 0;
 
}

The output of STRNSET() Function C Program is :

Please, Enter the String = Meeraacademy

The String after strset is = *****academy

 

Leave a Reply

Your email address will not be published. Required fields are marked *