Table of Contents
show
Use of strnset( ) function
#include<stdio.h>
#include<string.h>
int main()
{
char s[10], ch;
int n;
puts("Enter string1:");
gets(s);
puts("Enter the character:");
scanf("%c",&ch);
puts("Enter the number of characters to set:");
scanf("%d",&n);
puts("string before setting");
puts(s);
strnset(s,ch,n);
puts("string after setting");
puts(s);
return 0;
}
Output
Enter string1:
Hello
Enter the character:
a
Enter the number of characters to set:
3
string before setting
Hello
string after setting
aaalo
Views: 0