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
What is void c?
What is preprocessor with example?
Difference between macros and inline functions? Can a function be forced as inline?
What is this infamous null pointer, anyway?
Why is sizeof () an operator and not a function?
5 Write an Algorithm to find the maximum and minimum items in a set of ānā element.
Explain is it valid to address one element beyond the end of an array?
Are bit fields portable?
What is the most efficient way to count the number of bits which are set in an integer?
Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given
Is null equal to 0 in sql?
Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.
What is function prototype in c with example?
Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?
What functions are used for dynamic memory allocation in c language?