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

Fifty minutes ago if it was four times as many mints past 3 o clock. how many minutes is it to six o'clock n how....?????

3 Answers   TCS,


how 2 compile & execute c program with out using editor?

2 Answers   HP,


which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;

0 Answers  


what's the return value of malloc()

9 Answers  


What is a C array and illustrate the how is it different from a list.

1 Answers   Amazon,


GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA

0 Answers  


write a program which counts a product of array elements lower than 10.

1 Answers  


If the size of int data type is two bytes, what is the range of signed int data type?

0 Answers  


Difference between strcpy() and memcpy() function?

0 Answers  


Can you think of a way when a program crashed before reaching main? If yes how?

2 Answers  


How can a program be made to print the name of a source file where an error occurs?

0 Answers  


What is typedf?

0 Answers  


Categories