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

If i have an array 0 to 99 i.e,(Size 100) I place the values 1 to 100 randomly like a[0]=29,a[1]=56 upto array[99].. the values are only between 1 to 100. getting the array values by using scanf.. If i entered one wrong element value line a[56]=108. how can i find it.. and also how to find the missing value in 1 to 100.. and i want to replace the missing values.. any one of them know please post your answer..

1596


Why do we use & in c?

595


When is the “void” keyword used in a function?

843


What are the restrictions of a modulus operator?

641


What is volatile c?

527






Does c have circular shift operators?

734


What is the difference between array and pointer?

571


Why c is faster than c++?

636


Why is c called c?

635


How do you print an address?

751


Is it acceptable to declare/define a variable in a c header?

688


How can I call a function with an argument list built up at run time?

643


If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?

782


What is .obj file in c?

650


What is a floating point in c?

607