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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain two-dimensional array.

808


Explain what is the advantage of a random access file?

884


In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.

1589


I just typed in this program, and it is acting strangely. Can you see anything wrong with it?

756


How can I use a preprocessorif expression to ?

774


An arrangement of information in memory in such a way that it can be easily accessed and processed by a programming language a) string b) data structure c) pointers d) array

886


Explain do array subscripts always start with zero?

935


What is advantage of pointer in c?

896


What is the most efficient way to count the number of bits which are set in an integer?

808


a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none

953


Is file a keyword in c?

676


about c language

1790


What is difference between static and global variable in c?

747


What is signed and unsigned?

817


What is a pointer in c plus plus?

899