Explain in detail how strset (string handling function
works )pls explain it with an example.



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

Post New Answer

More C Interview Questions

What is pass by value in c?

0 Answers  


What is the best way to comment out a section of code that contains comments?

0 Answers  


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

4 Answers   TCS,


How pointers are declared?

0 Answers  


print out of string in this format; 1. "rajesh" 2. \n 3. %d

5 Answers   mpower,






compare array with pointer?

1 Answers  


Stimulate calculators to perform addition,subtraction,multiplication and division on two numbers using if/else statement?

1 Answers   IBM,


What is gets() function?

0 Answers  


What is the difference between printf and scanf )?

0 Answers  


What language is lisp written in?

0 Answers  


What does the format %10.2 mean when included in a printf statement?

0 Answers  


How can you increase the allowable number of simultaneously open files?

0 Answers  


Categories