Explain in detail how strset (string handling function
works )pls explain it with an example.
Answer / lakshman
strnset - strset - Set Bytes in String
Syntax
#include <string.h>
char *strnset(char *string, int c, size_t n);
char *strset(char *string, int c);
Example:
#include <stdio.h>
#include <string.h>
int main(void)
{
char *str = "abcdefghi";
printf("This is the string: %s\n", str);
printf("This is the string after strnset: %s\n",
strnset(str, 'x', 4));
printf("This is the string after strset: %s\n",
strset(str, 'k'));
return 0;
/****************************************************************************
The output should be:
This is the string: abcdefghi
This is the string after strnset: xxxxefghi
This is the string after strset: kkkkkkkkk
****************************************************************************/
}
Is This Answer Correct ? | 11 Yes | 12 No |
What is pass by value in c?
What is the best way to comment out a section of code that contains comments?
how does the C compiler interpret the following two statements p=p+x; q=q+y; a.p=p+x; q=q+y b.p=p+xq=q+y c.p=p+xq; q=q+y d.p=p+x/q=q+y
How pointers are declared?
print out of string in this format; 1. "rajesh" 2. \n 3. %d
compare array with pointer?
Stimulate calculators to perform addition,subtraction,multiplication and division on two numbers using if/else statement?
What is gets() function?
What is the difference between printf and scanf )?
What language is lisp written in?
What does the format %10.2 mean when included in a printf statement?
How can you increase the allowable number of simultaneously open files?