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
Can the “if” function be used in comparing strings?
What is the most efficient way to count the number of bits which are set in an integer?
What is the basic structure of c?
What is c language and why we use it?
What is the difference between fread buffer() and fwrite buffer()?
What is the explanation for modular programming?
How many main () function we can have in a project?
Explain how do you override a defined macro?
How many identifiers are there in c?
write a c program to find the sum of five entered numbers using an array named number
What are the advantages of union?
What is the maximum no. of arguments that can be given in a command line in C.?
general for is %wd,f-d; in this system "w" means a) 'w' represent total width of digits b) 'w' represent width which includes the digits before,after decimal place and the decimal point c) 'w' represent width which includes the digits before only d) 'w' represent width after decimal place only
Is it possible to have a function as a parameter in another function?
Explain Basic concepts of C language?