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
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..
Why do we use & in c?
When is the “void” keyword used in a function?
What are the restrictions of a modulus operator?
What is volatile c?
Does c have circular shift operators?
What is the difference between array and pointer?
Why c is faster than c++?
Why is c called c?
How do you print an address?
Is it acceptable to declare/define a variable in a c header?
How can I call a function with an argument list built up at run time?
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?
What is .obj file in c?
What is a floating point in c?